Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Today/Notification and Control Panel tests #1173

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ When device_agent.two_finger_tap fails, it generates a screenshot
When device_agent.long_press fails, it generates a screenshot
When device_agent.enter_text fails, it generates a screenshot
When device_agent.enter_text_in fails, it generates a screenshot

Scenario: Check that Today/Notification and Control Panel elements are visible for DeviceAgent
Then I can open Notifications tab in Today and Notifications page
And I can see Control Panel page elements
99 changes: 99 additions & 0 deletions calabash-cucumber/test/cucumber/features/steps/device_agent_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,102 @@ def expect_device_agent_to_screenshot(method, uiquery=nil)
When(/^device_agent\.enter_text_in fails, it generates a screenshot$/) do
expect_device_agent_to_screenshot(:enter_text_in)
end

Then(/^I can open Notifications tab in Today and Notifications page$/) do
# Timeout for views in Control/Notification Panels to appear
timeout = 5

if ipad?
puts "Test is not stable on iPad; skipping"
else
element = wait_for_view("*")
x = element["rect"]["center_x"]
final_y = element["rect"]["center_y"] + (element["rect"]["height"]/2)
pan_coordinates({:x => x, :y => 0},
{:x => x, :y => final_y},
{duration: 0.5})

# Waiting for animations is not good enough - the animation is outside of
# the AUT's view hierarchy
wait_for_external_animations

# Screenshots will not show the Control Panel page.
if ios9?
if uia_available?
if uia_call_windows([:button, {marked: 'Notifications'}], :isVisible) != 1
fail("Expected to see 'Notifications' element.")
end

uia_tap :button, marked: 'Notifications'
wait_for_external_animations

if uia_call_windows([:element, {marked: 'No Notifications'}], :isVisible) != 1
fail("Expected to see 'No Notifications' element")
end
else
message = "Timed out waiting for 'Notifications' view after #{timeout} seconds"
bridge_wait_for(message, {timeout: timeout}) do
!device_agent.query({marked: 'Notifications'}).empty?
end

device_agent.touch({:marked => 'Notifications'})

message = "Timed out waiting for 'No Notifications' view after #{timeout} seconds"
bridge_wait_for(message, {timeout: timeout}) do
!device_agent.query({marked: 'No Notifications'}).empty?
end
end
elsif ios10?
message = "Timed out waiting for 'No Notifications' view after #{timeout} seconds"
bridge_wait_for(message, {timeout: timeout}) do
!device_agent.query({marked: 'No Notifications'}).empty?
end
end
end
end

Then(/^I can see Control Panel page elements$/) do

# Timeout for views in Control/Notification Panels to appear
timeout = 5
message = "Timed out waiting for 'Wi-Fi' view after #{timeout} seconds"

if ipad?
puts "Test is not stable on iPad; skipping"
else
element = wait_for_view("*")
x = element["rect"]["center_x"]
start_y = element["rect"]["height"] - 10
final_y = element["rect"]["center_y"] + (element["rect"]["height"]/4)
pan_coordinates({:x => x, :y => start_y},
{:x => x, :y => final_y},
{duration: 0.5})

# Waiting for animations is not good enough - the animation is outside of
# the AUT's view hierarchy
wait_for_external_animations

# Screenshots will not show the Control Panel page.
if ios9?
if uia_available?
if uia_call_windows([:element, {marked: 'Wi-Fi'}], :isVisible) != 1
fail("Expected to see 'Wi-Fi' element.")
end
else
bridge_wait_for(message, {timeout: timeout}) do
!device_agent.query({marked: 'Wi-Fi'}).empty?
end
end
elsif ios10?
# We have to tap on Continue button from Welcome view after sim reset.
if !device_agent.query({marked: 'Continue'}).empty?
device.agent.touch({marked: 'Continue'})
wait_for_external_animations
end

bridge_wait_for(message, {timeout: timeout}) do
!device_agent.query({marked: 'Wi-Fi'}).empty?
end
end
end
end
52 changes: 26 additions & 26 deletions calabash-cucumber/test/cucumber/features/steps/pan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,37 +95,37 @@ def wait_for_external_animations
Then(/^I can pull up to see the Control Panel page$/) do
if ipad?
puts "Test is not stable on iPad; skipping"
end

element = wait_for_view("*")
x = element["rect"]["center_x"]
start_y = element["rect"]["height"] - 10
final_y = element["rect"]["center_y"] + (element["rect"]["height"]/4)
pan_coordinates({:x => x, :y => start_y},
{:x => x, :y => final_y},
{duration: 0.5})
else
element = wait_for_view("*")
x = element["rect"]["center_x"]
start_y = element["rect"]["height"] - 10
final_y = element["rect"]["center_y"] + (element["rect"]["height"]/4)
pan_coordinates({:x => x, :y => start_y},
{:x => x, :y => final_y},
{duration: 0.5})

# Waiting for animations is not good enough - the animation is outside of
# the AUT's view hierarchy
wait_for_external_animations
# Waiting for animations is not good enough - the animation is outside of
# the AUT's view hierarchy
wait_for_external_animations

# Screenshots will not show the Control Panel page.
if uia_available?
if uia_call_windows([:button, {marked: 'Camera'}], :isVisible) != 1
fail("Expected to see the iOS Control page.")
end
# Screenshots will not show the Control Panel page.
if uia_available?
if uia_call_windows([:button, {marked: 'Camera'}], :isVisible) != 1
fail("Expected to see the iOS Control page.")
end

# This will dismiss the control panel by touching the navigation bar.
touch("* marked:'Pan Menu'")
else
# Control Panel view is invisible to the LPServer and the DeviceAgent queries.
# Try to touch a row that is hidden by the page and expect no transition.
# This will dismiss the control panel by touching the navigation bar.
touch("* marked:'Pan Menu'")
else
# Control Panel view is invisible to the LPServer and the DeviceAgent queries.
# Try to touch a row that is hidden by the page and expect no transition.

# This will dismiss the control panel.
touch("* marked:'pan palette row'")
# This will dismiss the control panel.
touch("* marked:'pan palette row'")

if !query("* marked:'pan palette page'").empty?
fail("Expected to see the iOS Control panel page.")
if !query("* marked:'pan palette page'").empty?
fail("Expected to see the iOS Control panel page.")
end
end
end

Expand Down