Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chrome/browser/chromeos/login/proxy_auth_dialog_browsertest.cc

Issue 869993003: Added test for proxy auth dialog on sign-in screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/files/file_path.h"
7 #include "base/macros.h"
8 #include "base/run_loop.h"
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/login/login_manager_test.h"
11 #include "chrome/browser/chromeos/login/startup_utils.h"
12 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
15 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
16 #include "chrome/browser/ui/login/login_prompt.h"
17 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/chrome_switches.h"
20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/web_ui.h"
22 #include "content/public/browser/web_ui_controller.h"
23 #include "content/public/test/browser_test_utils.h"
24 #include "content/public/test/test_utils.h"
25 #include "net/test/spawned_test_server/spawned_test_server.h"
26 #include "testing/gtest/include/gtest/gtest.h"
27
28 namespace chromeos {
29
30 namespace {
31
32 class ProxyAuthDialogWaiter : public content::WindowedNotificationObserver {
33 public:
34 ProxyAuthDialogWaiter()
35 : WindowedNotificationObserver(
36 chrome::NOTIFICATION_AUTH_NEEDED,
37 base::Bind(&ProxyAuthDialogWaiter::SetLoginHandler,
38 base::Unretained(this))),
39 login_handler_(nullptr) {}
40
41 ~ProxyAuthDialogWaiter() override {}
42
43 LoginHandler* login_handler() const { return login_handler_; }
44
45 private:
46 bool SetLoginHandler(const content::NotificationSource& /* source */,
47 const content::NotificationDetails& details) {
48 login_handler_ =
49 content::Details<LoginNotificationDetails>(details)->handler();
50 return true;
51 }
52
53 LoginHandler* login_handler_;
54
55 DISALLOW_COPY_AND_ASSIGN(ProxyAuthDialogWaiter);
56 };
57
58 } // namespace
59
60 class ProxyAuthOnUserBoardScreenTest : public LoginManagerTest {
61 public:
62 ProxyAuthOnUserBoardScreenTest()
63 : LoginManagerTest(true /* should_launch_browser */),
64 proxy_server_(net::SpawnedTestServer::TYPE_BASIC_AUTH_PROXY,
65 net::SpawnedTestServer::kLocalhost,
66 base::FilePath()) {}
67
68 ~ProxyAuthOnUserBoardScreenTest() override {}
69
70 void SetUp() override {
71 ASSERT_TRUE(proxy_server_.Start());
72 LoginManagerTest::SetUp();
73 }
74
75 void SetUpCommandLine(base::CommandLine* command_line) override {
76 LoginManagerTest::SetUpCommandLine(command_line);
77 command_line->AppendSwitchASCII(::switches::kProxyServer,
78 proxy_server_.host_port_pair().ToString());
79 }
80
81 private:
82 net::SpawnedTestServer proxy_server_;
83
84 DISALLOW_COPY_AND_ASSIGN(ProxyAuthOnUserBoardScreenTest);
85 };
86
87 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest,
88 PRE_ProxyAuthDialogOnUserBoardScreen) {
89 RegisterUser("test-user@gmail.com");
90 StartupUtils::MarkOobeCompleted();
91 }
92
93 IN_PROC_BROWSER_TEST_F(ProxyAuthOnUserBoardScreenTest,
94 ProxyAuthDialogOnUserBoardScreen) {
95 LoginDisplayHost* login_display_host = LoginDisplayHostImpl::default_host();
96 WebUILoginView* web_ui_login_view = login_display_host->GetWebUILoginView();
97 OobeUI* oobe_ui =
98 static_cast<OobeUI*>(web_ui_login_view->GetWebUI()->GetController());
99
100 {
101 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
102 ProxyAuthDialogWaiter auth_dialog_waiter;
103 screen_waiter.Wait();
104 auth_dialog_waiter.Wait();
105
106 ASSERT_TRUE(auth_dialog_waiter.login_handler());
107 auth_dialog_waiter.login_handler()->CancelAuth();
108 }
109
110 {
111 OobeScreenWaiter screen_waiter(OobeDisplay::SCREEN_GAIA_SIGNIN);
112 ProxyAuthDialogWaiter auth_dialog_waiter;
113 ASSERT_TRUE(content::ExecuteScript(oobe_ui->web_ui()->GetWebContents(),
114 "window.domAutomationController.send(!!("
115 "$('add-user-button').click()"
116 "));"));
117 screen_waiter.Wait();
118 auth_dialog_waiter.Wait();
119 ASSERT_TRUE(auth_dialog_waiter.login_handler());
120 }
121 }
122
123 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698