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 // Boolean parameter is used to run this test for webview (true) and for | 60 class ProxyAuthOnUserBoardScreenTest : public LoginManagerTest { |
61 // iframe (false) GAIA sign in. | |
62 class ProxyAuthOnUserBoardScreenTest | |
63 : public LoginManagerTest, | |
64 public testing::WithParamInterface<bool> { | |
65 public: | 61 public: |
66 ProxyAuthOnUserBoardScreenTest() | 62 ProxyAuthOnUserBoardScreenTest() |
67 : LoginManagerTest(true /* should_launch_browser */), | 63 : LoginManagerTest(true /* should_launch_browser */), |
68 proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, | 64 proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY, |
69 net::SpawnedTestServer::kLocalhost, | 65 net::SpawnedTestServer::kLocalhost, |
70 base::FilePath()) { | 66 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 } | |
75 | 67 |
76 ~ProxyAuthOnUserBoardScreenTest() override {} | 68 ~ProxyAuthOnUserBoardScreenTest() override {} |
77 | 69 |
78 void SetUp() override { | 70 void SetUp() override { |
79 ASSERT_TRUE(proxy_server_.Start()); | 71 ASSERT_TRUE(proxy_server_.Start()); |
80 LoginManagerTest::SetUp(); | 72 LoginManagerTest::SetUp(); |
81 } | 73 } |
82 | 74 |
83 void SetUpCommandLine(base::CommandLine* command_line) override { | 75 void SetUpCommandLine(base::CommandLine* command_line) override { |
84 LoginManagerTest::SetUpCommandLine(command_line); | 76 LoginManagerTest::SetUpCommandLine(command_line); |
85 command_line->AppendSwitchASCII(::switches::kProxyServer, | 77 command_line->AppendSwitchASCII(::switches::kProxyServer, |
86 proxy_server_.host_port_pair().ToString()); | 78 proxy_server_.host_port_pair().ToString()); |
87 } | 79 } |
88 | 80 |
89 private: | 81 private: |
90 net::SpawnedTestServer proxy_server_; | 82 net::SpawnedTestServer proxy_server_; |
91 | 83 |
92 DISALLOW_COPY_AND_ASSIGN(ProxyAuthOnUserBoardScreenTest); | 84 DISALLOW_COPY_AND_ASSIGN(ProxyAuthOnUserBoardScreenTest); |
93 }; | 85 }; |
94 | 86 |
95 IN_PROC_BROWSER_TEST_P(ProxyAuthOnUserBoardScreenTest, | 87 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest, |
96 PRE_ProxyAuthDialogOnUserBoardScreen) { | 88 PRE_ProxyAuthDialogOnUserBoardScreen) { |
97 RegisterUser("test-user@gmail.com"); | 89 RegisterUser("test-user@gmail.com"); |
98 StartupUtils::MarkOobeCompleted(); | 90 StartupUtils::MarkOobeCompleted(); |
99 } | 91 } |
100 | 92 |
101 IN_PROC_BROWSER_TEST_P(ProxyAuthOnUserBoardScreenTest, | 93 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest, |
102 ProxyAuthDialogOnUserBoardScreen) { | 94 ProxyAuthDialogOnUserBoardScreen) { |
103 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); | 95 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host(); |
104 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); | 96 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView(); |
105 OobeUI* oobe_ui = | 97 OobeUI* oobe_ui = |
106 static_cast<OobeUI*>(web_ui_login_view->GetWebUI()->GetController()); | 98 static_cast<OobeUI*>(web_ui_login_view->GetWebUI()->GetController()); |
107 | 99 |
108 { | 100 { |
109 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); | 101 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER); |
110 ProxyAuthDialogWaiter auth_dialog_waiter; | 102 ProxyAuthDialogWaiter auth_dialog_waiter; |
111 screen_waiter.Wait(); | 103 screen_waiter.Wait(); |
112 auth_dialog_waiter.Wait(); | 104 auth_dialog_waiter.Wait(); |
113 | 105 |
114 ASSERT_TRUE(auth_dialog_waiter.login_handler()); | 106 ASSERT_TRUE(auth_dialog_waiter.login_handler()); |
115 auth_dialog_waiter.login_handler()->CancelAuth(); | 107 auth_dialog_waiter.login_handler()->CancelAuth(); |
116 } | 108 } |
117 | 109 |
118 { | 110 { |
119 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_GAIA_SIGNIN); | 111 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_GAIA_SIGNIN); |
120 ProxyAuthDialogWaiter auth_dialog_waiter; | 112 ProxyAuthDialogWaiter auth_dialog_waiter; |
121 ASSERT_TRUE(content::ExecuteScript(oobe_ui->web_ui()->GetWebContents(), | 113 ASSERT_TRUE(content::ExecuteScript(oobe_ui->web_ui()->GetWebContents(), |
122 "window.domAutomationController.send(!!(" | 114 "window.domAutomationController.send(!!(" |
123 "$('add-user-button').click()" | 115 "$('add-user-button').click()" |
124 "));")); | 116 "));")); |
125 screen_waiter.Wait(); | 117 screen_waiter.Wait(); |
126 auth_dialog_waiter.Wait(); | 118 auth_dialog_waiter.Wait(); |
127 ASSERT_TRUE(auth_dialog_waiter.login_handler()); | 119 ASSERT_TRUE(auth_dialog_waiter.login_handler()); |
128 } | 120 } |
129 } | 121 } |
130 | 122 |
131 INSTANTIATE_TEST_CASE_P(ProxyAuthOnUserBoardScreenTestSuite, | |
132 ProxyAuthOnUserBoardScreenTest, | |
133 testing::Bool()); | |
134 | |
135 } // namespace chromeos | 123 } // namespace chromeos |
OLD | NEW |