spec/lib/gametel/accessors_spec.rb in gametel-0.5.7 vs spec/lib/gametel/accessors_spec.rb in gametel-0.5.8
- old
+ new
@@ -1,10 +1,12 @@
require 'spec_helper'
class AccessorsSampleScreen
include Gametel
+ activity "SomeActivity"
+
list_item(:first_list_item_text, :text => 'first item')
list_item(:first_list_item_index, :index => 0)
list_item(:first_list_item_index_list, :index => 0, :list => 1)
text(:first_name_index, :index => 2)
text(:first_name_name, :content_description => 'Some name')
@@ -22,10 +24,12 @@
view(:view_text, :text => 'Any view text')
spinner(:spinner_id, :id => 'spinner_id')
spinner(:spinner_index, :index => 1)
progress(:progress_id, :id => 'progress_id')
progress(:progress_index, :index => 1)
+ image(:image_index, :index => 0)
+ image(:image_id, :id => 'image_id')
end
describe Gametel::Accessors do
context "when using Brazenhead" do
let(:screen) { AccessorsSampleScreen.new }
@@ -41,10 +45,22 @@
accumulator.stub(:clear)
accumulator.stub(:message)
device.stub(:send).and_return(result)
end
+ context "defining the activity on a screen" do
+ it "should define the active? method" do
+ screen.should respond_to :active?
+ end
+
+ it "should wait for the activity to become active" do
+ platform.should_receive(:wait_for_activity).with("SomeActivity")
+ platform.should_receive(:last_json)
+ screen.active?
+ end
+ end
+
context "list items" do
it "should know how to be chosen by text" do
platform.should_receive(:click_on_text)
screen.first_list_item_text
end
@@ -734,9 +750,33 @@
accumulator.should_receive(:is_shown)
result.should_receive(:body).and_return("true")
view = screen.progress_id_view
view.should be_shown
end
+ end
+ end
+
+ context "images" do
+ it "should click an image using the index" do
+ platform.should_receive(:click_on_image).with(0)
+ screen.click_image_index
+ end
+
+ it "should click an image by id" do
+ platform.should_receive(:click_on_view_by_id).with('image_id')
+ screen.click_image_id
+ end
+
+ it "should wait for a drawable when using index" do
+ platform.should_receive(:get_image).with(0)
+ platform.should_receive(:last_json).and_return({'hasDrawable' => 'true'})
+ screen.wait_for_image_index
+ end
+
+ it "should wait for a drawable when using index" do
+ platform.should_receive(:get_view_by_id).with(:id => 'image_id')
+ platform.should_receive(:last_json).and_return({'hasDrawable' => 'true'})
+ screen.wait_for_image_id
end
end
end
end