Skip to content

Commit

Permalink
Add Android Oreo detection (fnando#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
cillian authored and fnando committed Aug 31, 2017
1 parent acc24ac commit 7f9646b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/browser/opera.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def full_version
end

def match?
ua =~ /(Opera|OPR)/
ua =~ /(Opera|OPR\/)/
end
end
end
1 change: 1 addition & 0 deletions test/ua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ANDROID_KITKAT: Mozilla/5.0 (Linux; Android 4.4; Nexus 7 Build/KOT24) AppleWebKi
ANDROID_LOLLIPOP_50: Mozilla/5.0 (Linux; Android 5.0; Nexus 5 Build/LPX13D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.102 Mobile Safari/537.36
ANDROID_LOLLIPOP_51: Mozilla/5.0 (Linux; Android 5.1; Nexus 5 Build/LMY47I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.0.0 Mobile Safari/537.36; DailymotionEmbedSDK 1.0
ANDROID_NEXUS_PLAYER: Mozilla/5.0 (Linux; Android 5.0; Nexus Player Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.0
ANDROID_OREO: Mozilla/5.0 (Linux; Android 8.0.0; Pixel Build/OPR6.170623.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.03112.107 Mobile Safari/537.36
ANDROID_TV: Mozilla/5.0 (Linux; Android 5.0; ADT-1 Build/LRW87K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36
ANDROID_WEBVIEW: Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36
ANDROID_WITH_SAFARI: 'Mozilla/5.0 (Linux; U; Android 4.3; en-us; SCH-I535 Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
Expand Down
6 changes: 6 additions & 0 deletions test/unit/android_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class AndroidTest < Minitest::Test
assert browser.platform.android?(5.1)
end

test "detect android oreo (8.0)" do
browser = Browser.new(Browser["ANDROID_OREO"])
assert browser.platform.android?
assert browser.platform.android?(8.0)
end

test "detect android tv" do
browser = Browser.new(Browser["ANDROID_TV"])
assert browser.platform.android?
Expand Down
6 changes: 6 additions & 0 deletions test/unit/chrome_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class ChromeTest < Minitest::Test
assert_equal "26", browser.version
end

test "detects chrome not opera when android build number contains 'OPR'" do
browser = Browser.new(Browser["ANDROID_OREO"])

assert browser.chrome?
end

test "detects version by range" do
browser = Browser.new(Browser["CHROME"])
assert browser.chrome?(%w[>=5 <6])
Expand Down

0 comments on commit 7f9646b

Please sign in to comment.