forked from unboxed/icuke
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding the specs back into the project
- Loading branch information
Showing
6 changed files
with
699 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
require 'spec/spec_helper' | ||
require 'icuke' | ||
require 'cucumber/step_mother' | ||
require 'icuke/cucumber' | ||
require 'icuke/simulate' | ||
|
||
|
||
describe ICukeWorld do | ||
|
||
before(:each) do | ||
@simulator = [] | ||
@simulator.stub(:view) | ||
@simulator.stub(:fire_event) | ||
ICuke::Simulator.should_receive(:new).and_return(@simulator) | ||
@cuke_world = ICukeWorld.new | ||
@cuke_world.stub!(:sleep) | ||
xml = File.read('spec/fixtures/controls_page.xml') | ||
@cuke_world.stub(:response).and_return(xml) | ||
end | ||
|
||
context "when performing a swipe" do | ||
|
||
before(:each) do | ||
@simulator.should_receive(:fire_event) | ||
end | ||
|
||
it "should begin swipe at center of screen" do | ||
center_x, center_y = 160, 240 | ||
ICuke::Simulate::Gestures::Swipe.should_receive(:new). | ||
with(center_x, center_y, 160, 480, 0.015, {}) | ||
@cuke_world.swipe(:down) | ||
end | ||
|
||
it "should swipe to the bottom of the screen when swiping down" do | ||
bottom_y = 480 | ||
ICuke::Simulate::Gestures::Swipe.should_receive(:new). | ||
with(160, 240, 160, bottom_y, 0.015, {}) | ||
@cuke_world.swipe(:down) | ||
end | ||
|
||
it "should swipe to the top of the screen when swiping up" do | ||
top_y = 0 | ||
ICuke::Simulate::Gestures::Swipe.should_receive(:new). | ||
with(160, 240, 160, top_y, 0.015, {}) | ||
@cuke_world.swipe(:up) | ||
end | ||
|
||
it "should swipe to the left of the screen when swipping left" do | ||
min_x = 0 | ||
ICuke::Simulate::Gestures::Swipe.should_receive(:new). | ||
with(160, 240, min_x, 240, 0.015, {}) | ||
@cuke_world.swipe(:left) | ||
end | ||
|
||
it "should swipe to the right of the screen when swipping right" do | ||
max_x = 320 | ||
ICuke::Simulate::Gestures::Swipe.should_receive(:new). | ||
with(160, 240, max_x, 240, 0.015, {}) | ||
@cuke_world.swipe(:right) | ||
end | ||
|
||
end | ||
|
||
context "when performing a drag" do | ||
|
||
it "should fire an event" do | ||
@simulator.should_receive(:fire_event) | ||
@cuke_world.drag(1,2,3,4,{}) | ||
end | ||
|
||
it "should simulate a swipe from source to destination" do | ||
sx, sy, dx, dy = 10, 20, 30, 40 | ||
ICuke::Simulate::Gestures::Drag.should_receive(:new). | ||
with(sx, sy, dx, dy, 0.15, {}) | ||
@cuke_world.drag(sx, sy, dx, dy, {}) | ||
end | ||
|
||
end | ||
|
||
context "when performing a drag with a source" do | ||
|
||
it "should parse the input values" do | ||
ICuke::Simulate::Gestures::Drag.should_receive(:new). | ||
with(12, 24, 34, 44, 0.15, {}) | ||
@cuke_world.drag_with_source("12,24", "34,44") | ||
end | ||
|
||
end | ||
|
||
context "when draging a slider" do | ||
|
||
before(:each) do | ||
@screen = [] | ||
@screen.should_receive(:first_slider_element).at_least(:once) | ||
@screen.should_receive(:find_slider_button).at_least(:once).and_return([244, 287]) | ||
Screen.should_receive(:new).at_least(:once).and_return(@screen) | ||
end | ||
|
||
it "should set the destination properly" do | ||
{:up=>[244,267], :down=>[244,307], :right=>[264,287], :left=>[224,287]}.each do |d| | ||
ICuke::Simulate::Gestures::Drag.should_receive(:new). | ||
with(244, 287, d[1][0], d[1][1], 0.15, {}) | ||
@cuke_world.drag_slider_to('Label', d[0], 20) | ||
end | ||
end | ||
|
||
end | ||
|
||
context "when draging a slider to a percentage value" do | ||
|
||
before(:each) do | ||
@element = [] | ||
@screen = [] | ||
@screen.should_receive(:first_slider_element).and_return(@element) | ||
@screen.should_receive(:find_slider_button).and_return([244, 287]) | ||
Screen.should_receive(:new).and_return(@screen) | ||
end | ||
|
||
it "should identify the destination on the screen" do | ||
@screen.should_receive(:find_slider_percentage_location).with(@element, 30). | ||
and_return([230, 287]) | ||
ICuke::Simulate::Gestures::Drag.should_receive(:new). | ||
with(244, 287, 230, 287, 0.15, {}) | ||
@cuke_world.drag_slider_to_percentage("label", 30) | ||
end | ||
|
||
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,252 @@ | ||
<screen> | ||
<frame x="0.000000" y="0.000000" width="320.000000" height="480.000000"/> | ||
<UIWindow> | ||
<UILayoutContainerView> | ||
<UINavigationTransitionView> | ||
<UIViewControllerWrapperView> | ||
<UITableView> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="ControlsViewController.m: -(UISlider *)customSlider"> | ||
<frame x="20.000000" y="465.000000" width="280.000000" height="37.000000"/> | ||
</UILabel> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISlider *)customSlider"> | ||
<frame x="-0.000000" y="464.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCell> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="Customized Slider"> | ||
<frame x="20.000000" y="415.000000" width="280.000000" height="49.000000"/> | ||
</UILabel> | ||
<UISlider traits="" label="Custom" value="50%"> | ||
<frame x="184.000000" y="427.000000" width="120.000000" height="23.000000"/> | ||
<UIImageView/> | ||
<UIImageView/> | ||
<UIImageView/> | ||
</UISlider> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="Customized Slider"> | ||
<frame x="-0.000000" y="414.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="Custom" value="50%"> | ||
<frame x="184.000000" y="427.000000" width="120.000000" height="23.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCell> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="ControlsViewController.m: -(UISlider *)sliderCtl"> | ||
<frame x="20.000000" y="313.000000" width="280.000000" height="37.000000"/> | ||
</UILabel> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISlider *)sliderCtl"> | ||
<frame x="-0.000000" y="312.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCell> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="Standard Slider"> | ||
<frame x="20.000000" y="263.000000" width="280.000000" height="49.000000"/> | ||
</UILabel> | ||
<UISlider traits="" label="Standard slider" value="50%"> | ||
<frame x="184.000000" y="275.000000" width="120.000000" height="23.000000"/> | ||
<UIImageView/> | ||
<UIImageView/> | ||
<UIImageView/> | ||
</UISlider> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="Standard Slider"> | ||
<frame x="-0.000000" y="262.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="Standard slider" value="50%"> | ||
<frame x="184.000000" y="275.000000" width="120.000000" height="23.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCell> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="ControlsViewController.m: -(UISwitch *)switchCtl"> | ||
<frame x="20.000000" y="161.000000" width="280.000000" height="37.000000"/> | ||
</UILabel> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISwitch *)switchCtl"> | ||
<frame x="-0.000000" y="160.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCell> | ||
<UITableViewCell> | ||
<UIGroupTableViewCellBackground/> | ||
<UIView> | ||
<UILabel traits="static_text " label="Standard Switch"> | ||
<frame x="20.000000" y="111.000000" width="280.000000" height="49.000000"/> | ||
</UILabel> | ||
<UISwitch traits="button " label="Standard switch"> | ||
<frame x="208.000000" y="123.000000" width="94.000000" height="27.000000"/> | ||
<_UISwitchSlider> | ||
<UIImageView/> | ||
<UIImageView/> | ||
<UIView> | ||
<UILabel traits="static_text " label="ON"> | ||
<frame x="171.000000" y="123.000000" width="24.000000" height="27.000000"/> | ||
</UILabel> | ||
<UILabel traits="static_text " label="OFF"> | ||
<frame x="259.000000" y="123.000000" width="32.000000" height="27.000000"/> | ||
</UILabel> | ||
</UIView> | ||
<UIImageView/> | ||
</_UISwitchSlider> | ||
</UISwitch> | ||
</UIView> | ||
<UITableTextAccessibilityElement traits="" label="Standard Switch"> | ||
<frame x="-0.000000" y="110.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="button updates_frequently " label="Standard switch"> | ||
<frame x="208.000000" y="123.000000" width="94.000000" height="27.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCell> | ||
<UIImageView/> | ||
<UITableHeaderFooterView/> | ||
<UITableHeaderFooterView/> | ||
<UITableHeaderFooterView/> | ||
<UIImageView/> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="74.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UISwitch"> | ||
<frame x="0.000000" y="74.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="110.000000" width="320.000000" height="50.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Standard Switch"> | ||
<frame x="-0.000000" y="110.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="button updates_frequently " label="Standard switch"> | ||
<frame x="208.000000" y="123.000000" width="94.000000" height="27.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="160.000000" width="320.000000" height="39.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISwitch *)switchCtl"> | ||
<frame x="-0.000000" y="160.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="226.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UISlider"> | ||
<frame x="0.000000" y="226.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="262.000000" width="320.000000" height="50.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Standard Slider"> | ||
<frame x="-0.000000" y="262.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="Standard slider" value="50%"> | ||
<frame x="184.000000" y="275.000000" width="120.000000" height="23.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="312.000000" width="320.000000" height="39.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISlider *)sliderCtl"> | ||
<frame x="-0.000000" y="312.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="378.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UISlider"> | ||
<frame x="0.000000" y="378.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="414.000000" width="320.000000" height="50.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Customized Slider"> | ||
<frame x="-0.000000" y="414.000000" width="318.001068" height="50.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="Custom" value="50%"> | ||
<frame x="184.000000" y="427.000000" width="120.000000" height="23.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="464.000000" width="320.000000" height="39.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UISlider *)customSlider"> | ||
<frame x="-0.000000" y="464.000000" width="318.001068" height="39.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="530.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UIPageControl"> | ||
<frame x="0.000000" y="530.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Ten Pages"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="page 1 of 10"> | ||
<frame x="0.000000" y="0.000000" width="158.000000" height="25.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UIPageControl *)pageControl"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="682.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UIActivityIndicatorView"> | ||
<frame x="0.000000" y="682.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Style Gray"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UIActivityIndicatorView *)progressInd"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewSectionElement> | ||
<frame x="0.000000" y="834.000000" width="320.000000" height="36.000000"/> | ||
<UITableSectionPart traits="" label="UIProgressView"> | ||
<frame x="0.000000" y="834.000000" width="320.000000" height="36.000000"/> | ||
</UITableSectionPart> | ||
</UITableViewSectionElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="Style Default"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
<UIAccessibilityElementMockView traits="updates_frequently " label="Progress" value="50%"> | ||
<frame x="0.000000" y="0.000000" width="160.000000" height="24.000000"/> | ||
</UIAccessibilityElementMockView> | ||
</UITableViewCellAccessibilityElement> | ||
<UITableViewCellAccessibilityElement> | ||
<frame x="0.000000" y="0.000000" width="0.000000" height="0.000000"/> | ||
<UITableTextAccessibilityElement traits="" label="ControlsViewController.m: -(UIProgressView *)progressBar"> | ||
<frame x="-0.000000" y="0.000000" width="-1.998950" height="0.000000"/> | ||
</UITableTextAccessibilityElement> | ||
</UITableViewCellAccessibilityElement> | ||
</UITableView> | ||
</UIViewControllerWrapperView> | ||
</UINavigationTransitionView> | ||
<UINavigationBar> | ||
<UINavigationItemView traits="static_text " label="Controls"> | ||
<frame x="118.000000" y="28.000000" width="84.000000" height="27.000000"/> | ||
</UINavigationItemView> | ||
<UINavigationItemButtonView traits="button " label="Back"> | ||
<frame x="5.000000" y="27.000000" width="49.000000" height="30.000000"/> | ||
</UINavigationItemButtonView> | ||
</UINavigationBar> | ||
</UILayoutContainerView> | ||
</UIWindow> | ||
</screen> |
Oops, something went wrong.