Permalink
Browse files

renamed Page class to Screen

  • Loading branch information...
1 parent 425e47d commit 0be195bf2580c868e87c656a05360ee1a2db9178 @cheezy cheezy committed Jun 14, 2010
Showing with 53 additions and 53 deletions.
  1. +18 −18 lib/icuke/cucumber.rb
  2. +1 −1 lib/icuke/{page.rb → screen.rb}
  3. +10 −10 spec/cucumber_spec.rb
  4. +24 −24 spec/{page_spec.rb → screen_spec.rb}
View
@@ -2,7 +2,7 @@
require 'icuke/simulator'
require 'icuke/simulate'
-require 'icuke/page'
+require 'icuke/screen'
class ICukeWorld
include ICuke::Simulate::Gestures
@@ -21,8 +21,8 @@ def quit
@simulator.quit
end
- def page
- @page ||= Page.new(response)
+ def screen
+ @screen ||= Screen.new(response)
end
def response
@@ -38,8 +38,8 @@ def tap(label, options = {}, &block)
:pause => true
}.merge(options)
- element = page.first_tappable_element(label)
- x, y = page.element_position(element)
+ element = screen.first_tappable_element(label)
+ x, y = screen.element_position(element)
@simulator.fire_event(Tap.new(x, y, options))
@@ -51,7 +51,7 @@ def tap(label, options = {}, &block)
end
def swipe(direction, options = {})
- x,y,x2,y2 = page.swipe_coordinates(direction)
+ x,y,x2,y2 = screen.swipe_coordinates(direction)
@simulator.fire_event(Swipe.new(x, y, x2, y2, 0.015, options))
sleep(1)
refresh
@@ -70,8 +70,8 @@ def drag_with_source(source, destination)
end
def drag_slider_to(label, direction, distance)
- element = page.first_slider_element(label)
- x, y = page.find_slider_button(element)
+ element = screen.first_slider_element(label)
+ x, y = screen.find_slider_button(element)
dest_x, dest_y = x, y
modifier = direction_modifier(direction)
@@ -86,9 +86,9 @@ def drag_slider_to(label, direction, distance)
end
def drag_slider_to_percentage(label, percentage)
- element = page.first_slider_element(label)
- x, y = page.find_slider_button(element)
- dest_x, dest_y = page.find_slider_percentage_location(element, percentage)
+ element = screen.first_slider_element(label)
+ x, y = screen.find_slider_button(element)
+ dest_x, dest_y = screen.find_slider_percentage_location(element, percentage)
drag(x,y,dest_x,dest_y)
end
@@ -141,12 +141,12 @@ def type(textfield, text, options = {})
end
def scroll_to(text, options = {})
- x,y,x2,y2 = page.swipe_coordinates(swipe_direction(options[:direction]))
+ x,y,x2,y2 = screen.swipe_coordinates(swipe_direction(options[:direction]))
previous_response = response.dup
- while not page.onscreen?(text) do
+ while not screen.onscreen?(text) do
@simulator.fire_event(Swipe.new(x, y, x2, y2, 0.15, options))
refresh
- raise %Q{Content "#{text}" not found in: #{page}} if response == previous_response
+ raise %Q{Content "#{text}" not found in: #{screen}} if response == previous_response
end
end
@@ -162,7 +162,7 @@ def set_application_defaults(defaults)
def refresh
@response = nil
- @page = nil
+ @screen = nil
end
def swipe_direction(direction)
@@ -193,11 +193,11 @@ def direction_modifier(direction)
end
Then /^I should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, scope|
- raise %Q{Content "#{text}" not found in: #{page}} unless page.exists?(text, scope)
+ raise %Q{Content "#{text}" not found in: #{screen}} unless screen.exists?(text, scope)
end
Then /^I should not see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, scope|
- raise %Q{Content "#{text}" was found but was not expected in: #{page}} if page.exists?(text, scope)
+ raise %Q{Content "#{text}" was found but was not expected in: #{screen}} if screen.exists?(text, scope)
end
When /^I tap "([^\"]*)"$/ do |label|
@@ -233,5 +233,5 @@ def direction_modifier(direction)
end
Then /^show me the screen$/ do
- puts page.xml.to_s
+ puts screen.xml.to_s
end
@@ -1,6 +1,6 @@
require 'nokogiri'
-class Page
+class Screen
attr_reader :xml
def initialize(root)
View
@@ -88,10 +88,10 @@
context "when draging a slider" do
before(:each) do
- @page = []
- @page.should_receive(:first_slider_element).at_least(:once)
- @page.should_receive(:find_slider_button).at_least(:once).and_return([244, 287])
- Page.should_receive(:new).at_least(:once).and_return(@page)
+ @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
@@ -108,14 +108,14 @@
before(:each) do
@element = []
- @page = []
- @page.should_receive(:first_slider_element).and_return(@element)
- @page.should_receive(:find_slider_button).and_return([244, 287])
- Page.should_receive(:new).and_return(@page)
+ @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 page" do
- @page.should_receive(:find_slider_percentage_location).with(@element, 30).
+ 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::Swipe.should_receive(:new).
with(244, 287, 230, 287, 0.15, {})
@@ -1,72 +1,72 @@
require 'spec/spec_helper'
-require 'icuke/page'
+require 'icuke/screen'
-describe Page do
+describe Screen do
before(:all) do
@xml = File.read('spec/fixtures/controls_page.xml')
end
before(:each) do
- @page = Page.new(@xml)
+ @screen = Screen.new(@xml)
end
context "when testing if an element exists" do
it "should be able to search for a label" do
- @page.exists?("Customized Slider").should be_true
+ @screen.exists?("Customized Slider").should be_true
end
it "should be able to search for a label within a scope" do
# why does this not work with any scope?
- @page.exists?("Customized Slider", "UIWindow").should be_true
+ @screen.exists?("Customized Slider", "UIWindow").should be_true
end
it "should be able to search for a value" do
- @page.exists?("50%").should be_true
+ @screen.exists?("50%").should be_true
end
it "should be able to search for a node" do
- @page.exists?("UISlider").should be_true
+ @screen.exists?("UISlider").should be_true
end
it "should know when an element is visible on the screen" do
- @page.onscreen?("Standard Slider").should be_true
+ @screen.onscreen?("Standard Slider").should be_true
end
end
context "when finding a tappable element" do
it "should find an element with a button trait" do
- @page.first_tappable_element("Standard switch").name.should == "UISwitch"
+ @screen.first_tappable_element("Standard switch").name.should == "UISwitch"
end
it "should find an element with an updates_frequently trait" do
- @page.first_tappable_element("Custom").name.should == "UIAccessibilityElementMockView"
+ @screen.first_tappable_element("Custom").name.should == "UIAccessibilityElementMockView"
end
it "should find an element by its label" do
- @page.first_tappable_element("Customized Slider").name.should == "UILabel"
+ @screen.first_tappable_element("Customized Slider").name.should == "UILabel"
end
it "should raise an exception when the element is not found" do
- lambda{@page.first_tappable_element("does_not_exist")}.should raise_error
+ lambda{@screen.first_tappable_element("does_not_exist")}.should raise_error
end
end
context "when finding a slider element" do
it "should find a slider by its label" do
- @page.first_slider_element("Standard slider").name.should == "UISlider"
+ @screen.first_slider_element("Standard slider").name.should == "UISlider"
end
it "should find a slider by a UILabel withing the same parent" do
- @page.first_slider_element("Standard Slider").name.should == "UISlider"
+ @screen.first_slider_element("Standard Slider").name.should == "UISlider"
end
it "should raise an exception when the element is not found" do
- lambda{@page.first_slider_element("does_not_exist")}.should raise_error
+ lambda{@screen.first_slider_element("does_not_exist")}.should raise_error
end
end
@@ -83,7 +83,7 @@
set_frame_values(184,275,120,24)
{'50%' => 244, '100%' => 294, '75%' => 269, '25%' => 219, '0%' => 194}.each do |v|
@element['value'] = v[0]
- x, y = @page.find_slider_button(@element)
+ x, y = @screen.find_slider_button(@element)
x.should == v[1]
y.should == 287
end
@@ -93,7 +93,7 @@
set_frame_values(184,175,24,120)
{'50%' => 235, '100%' => 285, '75%' => 260,'25%' => 210, '0%' => 185}.each do |v|
@element['value'] = v[0]
- x,y = @page.find_slider_button(@element)
+ x,y = @screen.find_slider_button(@element)
x.should == 196
y.should == v[1]
end
@@ -112,7 +112,7 @@
it "should find percentage coordinate when slider is horizontal" do
set_frame_values(184,275,120,24)
{50 => 244, 100 => 294, 75 => 269, 25 => 219, 0 => 194}.each do |v|
- x,y = @page.find_slider_percentage_location(@element, v[0])
+ x,y = @screen.find_slider_percentage_location(@element, v[0])
x.should == v[1]
y.should == 287
end
@@ -121,7 +121,7 @@
it "should find percentage coordinate when slider is vertical" do
set_frame_values(184,175,24,120)
{50 => 235, 100 => 285, 75 => 260, 25 => 210, 0 => 185}.each do |v|
- x,y = @page.find_slider_percentage_location(@element, v[0])
+ x,y = @screen.find_slider_percentage_location(@element, v[0])
x.should == 196
y.should == v[1]
end
@@ -132,31 +132,31 @@
context "when finding the coordinates for a swipe" do
it "should start the coordinates with the center of the screen" do
- x,y,x2,y2 = @page.swipe_coordinates(:down)
+ x,y,x2,y2 = @screen.swipe_coordinates(:down)
x.should == 160
y.should == 240
end
it "should end the swipe at the top center when swiping up" do
- x,y,x2,y2 = @page.swipe_coordinates(:up)
+ x,y,x2,y2 = @screen.swipe_coordinates(:up)
x2.should == 160
y2.should == 0
end
it "should end the swipe at the bottom center when swiping down" do
- x,y,x2,y2 = @page.swipe_coordinates(:down)
+ x,y,x2,y2 = @screen.swipe_coordinates(:down)
x2.should == 160
y2.should == 480
end
it "should end the swipe at the right center when swiping right" do
- x,y,x2,y2 = @page.swipe_coordinates(:right)
+ x,y,x2,y2 = @screen.swipe_coordinates(:right)
x2.should == 320
y2.should == 240
end
it "should end the swipe at the left center when swiping left" do
- x,y,x2,y2 = @page.swipe_coordinates(:left)
+ x,y,x2,y2 = @screen.swipe_coordinates(:left)
x2.should == 0
y2.should == 240
end

0 comments on commit 0be195b

Please sign in to comment.