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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/chromeos/login/login_manager_test.h" | 10 #include "chrome/browser/chromeos/login/login_manager_test.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return true; | 50 return true; |
51 } | 51 } |
52 | 52 |
53 LoginHandler* login_handler_; | 53 LoginHandler* login_handler_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(ProxyAuthDialogWaiter); | 55 DISALLOW_COPY_AND_ASSIGN(ProxyAuthDialogWaiter); |
56 }; | 56 }; |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 class ProxyAuthOnUserBoardScreenTest : public LoginManagerTest { | 60 // Boolean parameter is used to run this test for webview (true) and for |
| 61 // iframe (false) GAIA sign in. |
| 62 class ProxyAuthOnUserBoardScreenTest |
| 63 : public LoginManagerTest, |
| 64 public testing::WithParamInterface<bool> { |
61 public: | 65 public: |
62 ProxyAuthOnUserBoardScreenTest() | 66 ProxyAuthOnUserBoardScreenTest() |
63 : LoginManagerTest(true /* should_launch_browser */), | 67 : LoginManagerTest(true /* should_launch_browser */), |
64 proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, | 68 proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, |
65 net::SpawnedTestServer::kLocalhost, | 69 net::SpawnedTestServer::kLocalhost, |
66 base::FilePath()) {} | 70 base::FilePath()) { |
| 71 // TODO(paulmeyer): Re-enable webview version of this test |
| 72 // (uncomment this line) once http://crbug.com/452452 is fixed. |
| 73 // set_use_webview(GetParam()); |
| 74 } |
67 | 75 |
68 ~ProxyAuthOnUserBoardScreenTest() override {} | 76 ~ProxyAuthOnUserBoardScreenTest() override {} |
69 | 77 |
70 void SetUp() override { | 78 void SetUp() override { |
71 ASSERT_TRUE(proxy_server_.Start()); | 79 ASSERT_TRUE(proxy_server_.Start()); |
72 LoginManagerTest::SetUp(); | 80 LoginManagerTest::SetUp(); |
73 } | 81 } |
74 | 82 |
75 void SetUpCommandLine(base::CommandLine* command_line) override { | 83 void SetUpCommandLine(base::CommandLine* command_line) override { |
76 LoginManagerTest::SetUpCommandLine(command_line); | 84 LoginManagerTest::SetUpCommandLine(command_line); |
77 command_line->AppendSwitchASCII(::switches::kProxyServer, | 85 command_line->AppendSwitchASCII(::switches::kProxyServer, |
78 proxy_server_.host_port_pair().ToString()); | 86 proxy_server_.host_port_pair().ToString()); |
79 } | 87 } |
80 | 88 |
81 private: | 89 private: |
82 net::SpawnedTestServer proxy_server_; | 90 net::SpawnedTestServer proxy_server_; |
83 | 91 |
84 DISALLOW_COPY_AND_ASSIGN(ProxyAuthOnUserBoardScreenTest); | 92 DISALLOW_COPY_AND_ASSIGN(ProxyAuthOnUserBoardScreenTest); |
85 }; | 93 }; |
86 | 94 |
87 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest, | 95 IN_PROC_BROWSER_TEST_P(ProxyAuthOnUserBoardScreenTest, |
88 PRE_ProxyAuthDialogOnUserBoardScreen) { | 96 PRE_ProxyAuthDialogOnUserBoardScreen) { |
89 RegisterUser("test-user@gmail.com"); | 97 RegisterUser("test-user@gmail.com"); |
90 StartupUtils::MarkOobeCompleted(); | 98 StartupUtils::MarkOobeCompleted(); |
91 } | 99 } |
92 | 100 |
93 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest, | 101 IN_PROC_BROWSER_TEST_P(ProxyAuthOnUserBoardScreenTest, |
94 ProxyAuthDialogOnUserBoardScreen) { | 102 ProxyAuthDialogOnUserBoardScreen) { |
95 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); | 103 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); |
96 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); | 104 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); |
97 OobeUI* oobe_ui = | 105 OobeUI* oobe_ui = |
98 static_cast<OobeUI*>(web_ui_login_view->GetWebUI()->GetController()); | 106 static_cast<OobeUI*>(web_ui_login_view->GetWebUI()->GetController()); |
99 | 107 |
100 { | 108 { |
101 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); | 109 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); |
102 ProxyAuthDialogWaiter auth_dialog_waiter; | 110 ProxyAuthDialogWaiter auth_dialog_waiter; |
103 screen_waiter.Wait(); | 111 screen_waiter.Wait(); |
104 auth_dialog_waiter.Wait(); | 112 auth_dialog_waiter.Wait(); |
105 | 113 |
106 ASSERT_TRUE(auth_dialog_waiter.login_handler()); | 114 ASSERT_TRUE(auth_dialog_waiter.login_handler()); |
107 auth_dialog_waiter.login_handler()->CancelAuth(); | 115 auth_dialog_waiter.login_handler()->CancelAuth(); |
108 } | 116 } |
109 | 117 |
110 { | 118 { |
111 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_GAIA_SIGNIN); | 119 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_GAIA_SIGNIN); |
112 ProxyAuthDialogWaiter auth_dialog_waiter; | 120 ProxyAuthDialogWaiter auth_dialog_waiter; |
113 ASSERT_TRUE(content::ExecuteScript(oobe_ui->web_ui()->GetWebContents(), | 121 ASSERT_TRUE(content::ExecuteScript(oobe_ui->web_ui()->GetWebContents(), |
114 "window.domAutomationController.send(!!(" | 122 "window.domAutomationController.send(!!(" |
115 "$('add-user-button').click()" | 123 "$('add-user-button').click()" |
116 "));")); | 124 "));")); |
117 screen_waiter.Wait(); | 125 screen_waiter.Wait(); |
118 auth_dialog_waiter.Wait(); | 126 auth_dialog_waiter.Wait(); |
119 ASSERT_TRUE(auth_dialog_waiter.login_handler()); | 127 ASSERT_TRUE(auth_dialog_waiter.login_handler()); |
120 } | 128 } |
121 } | 129 } |
122 | 130 |
| 131 INSTANTIATE_TEST_CASE_P(ProxyAuthOnUserBoardScreenTestSuite, |
| 132 ProxyAuthOnUserBoardScreenTest, |
| 133 testing::Bool()); |
| 134 |
123 } // namespace chromeos | 135 } // namespace chromeos |
OLD | NEW |