-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testcases added and rakefile updated
- Loading branch information
Showing
3 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
# | ||
# To change this template, choose Tools | Templates | ||
# and open the template in the editor. | ||
require "rake" | ||
require "rake/testtask" | ||
require "rake/rdoctask" | ||
require "rake/clean" | ||
require "rake/gempackagetask" | ||
|
||
task :default => [ :test ] | ||
task :test => [ :test_units ] | ||
|
||
desc "run unit tests in test/unit" | ||
rt = Rake::TestTask.new("test_units") do |t| | ||
t.libs << "test/unit" | ||
t.pattern = "test/test_*.rb" | ||
t.verbose = true | ||
end | ||
|
||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
desc "create rdoc in /doc" | ||
rd = Rake::RDocTask.new("doc") do |rd| | ||
rd.main = "README" | ||
rd.rdoc_files.include("README", "lib/*.rb") | ||
rd.options << "--all" | ||
rd.rdoc_dir = "rdoc" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "test/unit" | ||
|
||
require "rswing" | ||
|
||
class TestButton < Test::Unit::TestCase | ||
include RSwing::Components | ||
|
||
def setup | ||
@button = Button.new "hello world" | ||
end | ||
|
||
def test_events | ||
assert(@button.respond_to?(:on_click), "no on_click method available!") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "test/unit" | ||
|
||
require "rswing" | ||
|
||
class TestContainer < Test::Unit::TestCase | ||
include RSwing::Components | ||
|
||
def setup | ||
@container = Frame.new "my frame" | ||
@button = Button.new "by button" | ||
end | ||
|
||
def test_indexer | ||
btn = Button.new "my button", :belongs_to => @container, :name => :button | ||
assert_equal(@container[:button], btn) | ||
end | ||
|
||
def test_add | ||
@container.add @button | ||
assert(@container.components.include?(@button), "container should have button!") | ||
end | ||
|
||
def test_remove | ||
test_add | ||
@container.remove @button | ||
assert(! @container.components.include?(@button), "container should not have button!") | ||
end | ||
|
||
def test_add_if_requested | ||
Container.add_if_requested @button, {} | ||
assert(! @container.components.include?(@button), "container should not have button!") | ||
|
||
Container.add_if_requested @button, :belongs_to => @container, :name => :new_button | ||
assert(@container.components.include?(@button), "container now should have button!") | ||
assert_not_nil(@container[:new_button], "container now should have button!") | ||
end | ||
|
||
def test_components | ||
frame = Frame.new "my frame" | ||
panel = Panel.new | ||
|
||
frame.add @button | ||
assert(frame.components.include?(@button), "frame should have button!") | ||
|
||
panel.add @button | ||
assert(panel.components.include?(@button), "panel should have button!") | ||
end | ||
end |