Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" | 7 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| 8 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 8 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 9 #include "chromeos/chromeos_switches.h" | 9 #include "chromeos/chromeos_switches.h" |
| 10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| 11 #include "content/public/test/test_utils.h" | 11 #include "content/public/test/test_utils.h" |
| 12 #include "media/base/media_switches.h" | |
| 12 | 13 |
| 13 namespace chromeos { | 14 namespace chromeos { |
| 14 | 15 |
| 15 class WebviewLoginTest : public OobeBaseTest { | 16 class WebviewLoginTest : public OobeBaseTest { |
| 16 public: | 17 public: |
| 17 WebviewLoginTest() {} | 18 WebviewLoginTest() {} |
| 18 ~WebviewLoginTest() override {} | 19 ~WebviewLoginTest() override {} |
| 19 | 20 |
| 20 void SetUpCommandLine(base::CommandLine* command_line) override { | 21 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 21 command_line->AppendSwitch(switches::kOobeSkipPostLogin); | 22 command_line->AppendSwitch(switches::kOobeSkipPostLogin); |
| 23 command_line->AppendSwitch(::switches::kUseFakeDeviceForMediaStream); | |
| 22 OobeBaseTest::SetUpCommandLine(command_line); | 24 OobeBaseTest::SetUpCommandLine(command_line); |
| 23 } | 25 } |
| 24 | 26 |
| 25 protected: | 27 protected: |
| 26 void ClickNext() { | 28 void ClickNext() { |
| 27 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); | 29 ExecuteJsInSigninFrame("document.getElementById('nextButton').click();"); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void ExpectIdentifierPage() { | 32 void ExpectIdentifierPage() { |
| 31 // First page: no back button, no close button, refresh button, #identifier | 33 // First page: no back button, no close button, refresh button, #identifier |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 JsExpect(frame_url + ".search('flow=nosignup') != -1"); | 126 JsExpect(frame_url + ".search('flow=nosignup') != -1"); |
| 125 } | 127 } |
| 126 | 128 |
| 127 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, EmailPrefill) { | 129 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, EmailPrefill) { |
| 128 WaitForGaiaPageLoad(); | 130 WaitForGaiaPageLoad(); |
| 129 JS().ExecuteAsync("Oobe.showSigninUI('user@example.com')"); | 131 JS().ExecuteAsync("Oobe.showSigninUI('user@example.com')"); |
| 130 WaitForGaiaPageReload(); | 132 WaitForGaiaPageReload(); |
| 131 EXPECT_EQ(fake_gaia_->prefilled_email(), "user@example.com"); | 133 EXPECT_EQ(fake_gaia_->prefilled_email(), "user@example.com"); |
| 132 } | 134 } |
| 133 | 135 |
| 136 // Tests that requesting webcam access from the login screen works correctly. | |
| 137 // This is needed for taking profile pictures. | |
| 138 IN_PROC_BROWSER_TEST_F(WebviewLoginTest, RequestCamera) { | |
|
achuithb
2017/04/05 00:55:36
Thanks for adding this.
| |
| 139 WaitForGaiaPageLoad(); | |
| 140 | |
| 141 // Video devices should be allowed from the login screen. | |
| 142 content::WebContents* web_contents = GetLoginUI()->GetWebContents(); | |
| 143 bool getUserMediaSuccess = false; | |
| 144 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 145 web_contents->GetMainFrame(), | |
| 146 "navigator.getUserMedia(" | |
| 147 " {video: true}," | |
| 148 " function() { window.domAutomationController.send(true); }," | |
| 149 " function() { window.domAutomationController.send(false); });", | |
| 150 &getUserMediaSuccess)); | |
| 151 ASSERT_TRUE(getUserMediaSuccess); | |
|
emaxx
2017/04/06 02:41:47
nit: Replace with EXPECT_TRUE here and in other pl
raymes
2017/04/10 00:16:48
Done.
| |
| 152 | |
| 153 // Audio devices should be denied from the login screen. | |
| 154 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 155 web_contents->GetMainFrame(), | |
| 156 "navigator.getUserMedia(" | |
| 157 " {audio: true}," | |
| 158 " function() { window.domAutomationController.send(true); }," | |
| 159 " function() { window.domAutomationController.send(false); });", | |
| 160 &getUserMediaSuccess)); | |
| 161 ASSERT_FALSE(getUserMediaSuccess); | |
| 162 } | |
| 163 | |
| 134 } // namespace chromeos | 164 } // namespace chromeos |
| OLD | NEW |