Skip to content

Commit

Permalink
tweak unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed May 4, 2019
1 parent b936d01 commit 2d8a8f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions test/functional/ios/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ def test_page_source

assert !source.include?('AppiumAUT')
assert source.include?('XCUIElementTypeApplication type')
assert_in_delta 80, xml[2].elements.each('//*') { |v| v }.map(&:name).size, 5 # rubocop:disable Lint/Void:
assert xml[2].elements.each('//*') { |v| v }.map(&:name).size > 70 # rubocop:disable Lint/Void

s_source = @@driver.page_source
s_xml = REXML::Document.new s_source

assert s_source.include?('AppiumAUT')
assert s_source.include?('XCUIElementTypeApplication type')

assert [78, 81].include?(s_xml[2].elements.each('//*') { |v| v }.map(&:name).size) # rubocop:disable Lint/Void:
# Roughly matching...
assert s_xml[2].elements.each('//*') { |v| v }.map(&:name).size > 70 # rubocop:disable Lint/Void
end

def test_location
Expand Down
8 changes: 6 additions & 2 deletions test/unit/android/device/mjsonwp/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ def test_current_package

def test_get_system_bars
stub_request(:get, "#{SESSION}/appium/device/system_bars")
.to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: {
statusBar: { visible: true, x: 0, y: 0, width: 1080, height: 63 },
navigationBar: { visible: true, x: 0, y: 1794, width: 1080, height: 126 }
} }.to_json)

@driver.get_system_bars
info = @driver.get_system_bars

assert_requested(:get, "#{SESSION}/appium/device/system_bars", times: 1)
assert_equal({ 'visible' => true, 'x' => 0, 'y' => 0, 'width' => 1080, 'height' => 63 }, info['statusBar'])
end

def test_get_display_density
Expand Down
8 changes: 6 additions & 2 deletions test/unit/android/device/w3c/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ def test_current_package

def test_get_system_bars
stub_request(:get, "#{SESSION}/appium/device/system_bars")
.to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: {
statusBar: { visible: true, x: 0, y: 0, width: 1080, height: 63 },
navigationBar: { visible: true, x: 0, y: 1794, width: 1080, height: 126 }
} }.to_json)

@driver.get_system_bars
info = @driver.get_system_bars

assert_requested(:get, "#{SESSION}/appium/device/system_bars", times: 1)
assert_equal({ 'visible' => true, 'x' => 0, 'y' => 0, 'width' => 1080, 'height' => 63 }, info['statusBar'])
end

def test_get_display_density
Expand Down

0 comments on commit 2d8a8f3

Please sign in to comment.