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

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

Issue 23449023: Add kiosk browser tests for network configuration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix flakiness Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chrome_browser_main.h" 11 #include "chrome/browser/chrome_browser_main.h"
12 #include "chrome/browser/chrome_browser_main_extra_parts.h" 12 #include "chrome/browser/chrome_browser_main_extra_parts.h"
13 #include "chrome/browser/chrome_content_browser_client.h" 13 #include "chrome/browser/chrome_content_browser_client.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 16 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
17 #include "chrome/browser/chromeos/login/app_launch_controller.h" 17 #include "chrome/browser/chromeos/login/app_launch_controller.h"
18 #include "chrome/browser/chromeos/login/app_launch_signin_screen.h"
18 #include "chrome/browser/chromeos/login/existing_user_controller.h" 19 #include "chrome/browser/chromeos/login/existing_user_controller.h"
19 #include "chrome/browser/chromeos/login/login_display_host_impl.h" 20 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
21 #include "chrome/browser/chromeos/login/mock_user_manager.h"
20 #include "chrome/browser/chromeos/login/webui_login_display.h" 22 #include "chrome/browser/chromeos/login/webui_login_display.h"
21 #include "chrome/browser/chromeos/login/wizard_controller.h" 23 #include "chrome/browser/chromeos/login/wizard_controller.h"
24 #include "chrome/browser/chromeos/settings/cros_settings.h"
25 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
22 #include "chrome/browser/extensions/extension_service.h" 26 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/extensions/extension_system.h" 27 #include "chrome/browser/extensions/extension_system.h"
24 #include "chrome/browser/lifetime/application_lifetime.h" 28 #include "chrome/browser/lifetime/application_lifetime.h"
25 #include "chrome/browser/prefs/scoped_user_pref_update.h" 29 #include "chrome/browser/prefs/scoped_user_pref_update.h"
26 #include "chrome/browser/profiles/profile_manager.h" 30 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" 32 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
29 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/extensions/extension.h" 35 #include "chrome/common/extensions/extension.h"
32 #include "chrome/test/base/in_process_browser_test.h" 36 #include "chrome/test/base/in_process_browser_test.h"
33 #include "chrome/test/base/interactive_test_utils.h" 37 #include "chrome/test/base/interactive_test_utils.h"
34 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
35 #include "chromeos/chromeos_switches.h" 39 #include "chromeos/chromeos_switches.h"
36 #include "content/public/browser/notification_observer.h" 40 #include "content/public/browser/notification_observer.h"
37 #include "content/public/browser/notification_registrar.h" 41 #include "content/public/browser/notification_registrar.h"
38 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
39 #include "content/public/test/test_utils.h" 43 #include "content/public/test/test_utils.h"
40 #include "google_apis/gaia/gaia_switches.h" 44 #include "google_apis/gaia/gaia_switches.h"
41 #include "net/base/host_port_pair.h" 45 #include "net/base/host_port_pair.h"
46 #include "net/base/network_change_notifier.h"
42 #include "net/dns/mock_host_resolver.h" 47 #include "net/dns/mock_host_resolver.h"
43 #include "net/test/embedded_test_server/embedded_test_server.h" 48 #include "net/test/embedded_test_server/embedded_test_server.h"
44 #include "net/test/embedded_test_server/http_request.h" 49 #include "net/test/embedded_test_server/http_request.h"
45 #include "net/test/embedded_test_server/http_response.h" 50 #include "net/test/embedded_test_server/http_response.h"
46 #include "testing/gmock/include/gmock/gmock.h" 51 #include "testing/gmock/include/gmock/gmock.h"
47 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
48 53
49 using namespace net::test_server; 54 using namespace net::test_server;
50 55
51 namespace chromeos { 56 namespace chromeos {
52 57
53 namespace { 58 namespace {
54 59
55 const char kWebstoreDomain[] = "cws.com"; 60 const char kWebstoreDomain[] = "cws.com";
56 const base::FilePath kServiceLogin("chromeos/service_login.html"); 61 const base::FilePath kServiceLogin("chromeos/service_login.html");
57 62
58 // Webstore data json is in 63 // Webstore data json is in
59 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ 64 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/
60 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe 65 // detail/ggbflgnkafappblpkiflbgpmkfdpnhhe
61 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe"; 66 const char kTestKioskApp[] = "ggbflgnkafappblpkiflbgpmkfdpnhhe";
62 67
68 // Timeout while waiting for network connectivity during tests.
69 const int kTestNetworkTimeoutSeconds = 1;
70
71 // Email of owner account for test.
72 const char kTestOwnerEmail[] = "owner@example.com";
73
63 // Helper function for GetConsumerKioskModeStatusCallback. 74 // Helper function for GetConsumerKioskModeStatusCallback.
64 void ConsumerKioskModeStatusCheck( 75 void ConsumerKioskModeStatusCheck(
65 KioskAppManager::ConsumerKioskModeStatus* out_status, 76 KioskAppManager::ConsumerKioskModeStatus* out_status,
66 const base::Closure& runner_quit_task, 77 const base::Closure& runner_quit_task,
67 KioskAppManager::ConsumerKioskModeStatus in_status) { 78 KioskAppManager::ConsumerKioskModeStatus in_status) {
68 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status; 79 LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status;
69 *out_status = in_status; 80 *out_status = in_status;
70 runner_quit_task.Run(); 81 runner_quit_task.Run();
71 } 82 }
72 83
73 // Helper KioskAppManager::EnableKioskModeCallback implementation. 84 // Helper KioskAppManager::EnableKioskModeCallback implementation.
74 void ConsumerKioskModeLockCheck( 85 void ConsumerKioskModeLockCheck(
75 bool* out_locked, 86 bool* out_locked,
76 const base::Closure& runner_quit_task, 87 const base::Closure& runner_quit_task,
77 bool in_locked) { 88 bool in_locked) {
78 LOG(INFO) << "kioks locked = " << in_locked; 89 LOG(INFO) << "kiosk locked = " << in_locked;
79 *out_locked = in_locked; 90 *out_locked = in_locked;
80 runner_quit_task.Run(); 91 runner_quit_task.Run();
81 } 92 }
82 93
94 // Helper function for WaitForNetworkTimeOut.
95 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) {
96 runner_quit_task.Run();
97 }
98
83 } // namespace 99 } // namespace
84 100
101 // Fake NetworkChangeNotifier used to simulate network connectivity.
102 class FakeNetworkChangeNotifier : public net::NetworkChangeNotifier {
103 public:
104 FakeNetworkChangeNotifier() : connection_type_(CONNECTION_NONE) {}
105
106 virtual ConnectionType GetCurrentConnectionType() const OVERRIDE {
107 return connection_type_;
108 }
109
110 void GoOnline() {
111 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
112 }
113
114 void GoOffline() {
115 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE);
116 }
117
118 void SetConnectionType(ConnectionType type) {
119 connection_type_ = type;
120 NotifyObserversOfNetworkChange(type);
121 base::RunLoop().RunUntilIdle();
122 }
123
124 virtual ~FakeNetworkChangeNotifier() {}
125
126 private:
127 ConnectionType connection_type_;
128 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier);
129 };
130
131 // A waiter that blocks until the expected oobe screen is reached.
132 class OobeScreenWaiter : public OobeUI::Observer {
133 public:
134 explicit OobeScreenWaiter(OobeDisplay::Screen expected_screen)
135 : waiting_for_screen_(false),
136 expected_screen_(expected_screen) {
137 }
138
139 virtual ~OobeScreenWaiter() {
140 if (waiting_for_screen_) {
141 GetOobeUI()->RemoveObserver(this);
142 }
143 }
144
145 void Wait() {
146 if (GetOobeUI()->current_screen() == expected_screen_) {
147 return;
148 }
149
150 waiting_for_screen_ = true;
151 GetOobeUI()->AddObserver(this);
152
153 runner_ = new content::MessageLoopRunner;
154 runner_->Run();
155 ASSERT_EQ(expected_screen_, GetOobeUI()->current_screen());
156 ASSERT_FALSE(waiting_for_screen_);
157 }
158
159 // OobeUI::Observer implementation:
160 virtual void OnCurrentScreenChanged(
161 OobeDisplay::Screen current_screen,
162 OobeDisplay::Screen new_screen) OVERRIDE {
163 if (waiting_for_screen_ && new_screen == expected_screen_) {
164 runner_->Quit();
165 waiting_for_screen_ = false;
166 GetOobeUI()->RemoveObserver(this);
167 }
168 }
169
170 OobeUI* GetOobeUI() {
171 OobeUI* oobe_ui = static_cast<chromeos::LoginDisplayHostImpl*>(
172 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI();
173 CHECK(oobe_ui);
174 return oobe_ui;
175 }
176
177 private:
178 bool waiting_for_screen_;
179 OobeDisplay::Screen expected_screen_;
180 scoped_refptr<content::MessageLoopRunner> runner_;
181 };
182
85 class KioskTest : public InProcessBrowserTest, 183 class KioskTest : public InProcessBrowserTest,
86 // Param defining is multi-profiles enabled. 184 // Param defining is multi-profiles enabled.
87 public testing::WithParamInterface<bool> { 185 public testing::WithParamInterface<bool> {
88 public: 186 public:
89 KioskTest() { 187 KioskTest() {
90 set_exit_when_last_browser_closes(false); 188 set_exit_when_last_browser_closes(false);
91 } 189 }
92 190
93 virtual ~KioskTest() {} 191 virtual ~KioskTest() {}
94 192
95 protected: 193 protected:
96 virtual void SetUpOnMainThread() OVERRIDE { 194 virtual void SetUpOnMainThread() OVERRIDE {
97 test_server_.reset(new EmbeddedTestServer( 195 test_server_.reset(new EmbeddedTestServer(
98 content::BrowserThread::GetMessageLoopProxyForThread( 196 content::BrowserThread::GetMessageLoopProxyForThread(
99 content::BrowserThread::IO))); 197 content::BrowserThread::IO)));
100 CHECK(test_server_->InitializeAndWaitUntilReady()); 198 CHECK(test_server_->InitializeAndWaitUntilReady());
101 test_server_->RegisterRequestHandler( 199 test_server_->RegisterRequestHandler(
102 base::Bind(&KioskTest::HandleRequest, base::Unretained(this))); 200 base::Bind(&KioskTest::HandleRequest, base::Unretained(this)));
103 LOG(INFO) << "Set up http server at " << test_server_->base_url(); 201 LOG(INFO) << "Set up http server at " << test_server_->base_url();
104 202
105 const GURL gaia_url("http://localhost:" + test_server_->base_url().port()); 203 const GURL gaia_url("http://localhost:" + test_server_->base_url().port());
106 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 204 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
107 ::switches::kGaiaUrl, gaia_url.spec()); 205 ::switches::kGaiaUrl, gaia_url.spec());
206
207 mock_user_manager_.reset(new MockUserManager);
208 AppLaunchController::SkipSplashWaitForTesting();
209 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds);
108 } 210 }
109 211
110 virtual void CleanUpOnMainThread() OVERRIDE { 212 virtual void CleanUpOnMainThread() OVERRIDE {
213 // We need to clean up these objects in this specific order.
214 fake_network_notifier_.reset(NULL);
215 disable_network_notifier_.reset(NULL);
216
217 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
218 AppLaunchController::SetUserManagerForTesting(NULL);
219
111 // If the login display is still showing, exit gracefully. 220 // If the login display is still showing, exit gracefully.
112 if (LoginDisplayHostImpl::default_host()) { 221 if (LoginDisplayHostImpl::default_host()) {
113 base::MessageLoop::current()->PostTask(FROM_HERE, 222 base::MessageLoop::current()->PostTask(FROM_HERE,
114 base::Bind(&chrome::AttemptExit)); 223 base::Bind(&chrome::AttemptExit));
115 content::RunMessageLoop(); 224 content::RunMessageLoop();
116 } 225 }
117 226
118 // Clean up while main thread still runs. 227 // Clean up while main thread still runs.
119 // See http://crbug.com/176659. 228 // See http://crbug.com/176659.
120 KioskAppManager::Get()->CleanUp(); 229 KioskAppManager::Get()->CleanUp();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 298
190 void ReloadKioskApps() { 299 void ReloadKioskApps() {
191 KioskAppManager::Get()->AddApp(kTestKioskApp); 300 KioskAppManager::Get()->AddApp(kTestKioskApp);
192 } 301 }
193 302
194 void ReloadAutolaunchKioskApps() { 303 void ReloadAutolaunchKioskApps() {
195 KioskAppManager::Get()->AddApp(kTestKioskApp); 304 KioskAppManager::Get()->AddApp(kTestKioskApp);
196 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp); 305 KioskAppManager::Get()->SetAutoLaunchApp(kTestKioskApp);
197 } 306 }
198 307
308 void StartAppLaunchFromLoginScreen(bool has_connectivity) {
309 EnableConsumerKioskMode();
310
311 // Start UI, find menu entry for this app and launch it.
312 content::WindowedNotificationObserver login_signal(
313 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
314 content::NotificationService::AllSources());
315 chromeos::WizardController::SkipPostLoginScreensForTesting();
316 chromeos::WizardController* wizard_controller =
317 chromeos::WizardController::default_controller();
318 CHECK(wizard_controller);
319 wizard_controller->SkipToLoginForTesting();
320 login_signal.Wait();
321
322 // Wait for the Kiosk App configuration to reload, then launch the app.
323 content::WindowedNotificationObserver apps_loaded_signal(
324 chrome::NOTIFICATION_KIOSK_APPS_LOADED,
325 content::NotificationService::AllSources());
326 ReloadKioskApps();
327 apps_loaded_signal.Wait();
328
329 if (!has_connectivity)
330 SimulateNetworkOffline();
331
332 GetLoginUI()->CallJavascriptFunction(
333 "login.AppsMenuButton.runAppForTesting",
334 base::StringValue(kTestKioskApp));
335 }
336
337 void WaitForAppLaunchSuccess() {
338 SimulateNetworkOnline();
339
340 // Wait for the Kiosk App to launch.
341 content::WindowedNotificationObserver(
342 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
343 content::NotificationService::AllSources()).Wait();
344
345 // Check installer status.
346 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
347 chromeos::KioskAppLaunchError::Get());
348
349 // Check if the kiosk webapp is really installed for the default profile.
350 ASSERT_TRUE(ProfileManager::GetDefaultProfile());
351 const extensions::Extension* app =
352 extensions::ExtensionSystem::Get(ProfileManager::GetDefaultProfile())->
353 extension_service()->GetInstalledExtension(kTestKioskApp);
354 EXPECT_TRUE(app);
355
356 // Wait until the app terminates.
357 content::RunMessageLoop();
358 }
359
360 void SimulateNetworkOffline() {
361 disable_network_notifier_.reset(
362 new net::NetworkChangeNotifier::DisableForTest);
363
364 fake_network_notifier_.reset(new FakeNetworkChangeNotifier);
365 }
366
367 void SimulateNetworkOnline() {
368 if (fake_network_notifier_.get())
369 fake_network_notifier_->GoOnline();
370 }
371
372 void WaitForAppLaunchNetworkTimeout() {
373 if (GetAppLaunchController()->network_wait_timedout())
374 return;
375
376 scoped_refptr<content::MessageLoopRunner> runner =
377 new content::MessageLoopRunner;
378
379 base::Closure callback = base::Bind(
380 &OnNetworkWaitTimedOut, runner->QuitClosure());
381 AppLaunchController::SetNetworkTimeoutCallbackForTesting(&callback);
382
383 runner->Run();
384
385 CHECK(GetAppLaunchController()->network_wait_timedout());
386 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
387 }
388
199 void EnableConsumerKioskMode() { 389 void EnableConsumerKioskMode() {
200 scoped_ptr<bool> locked(new bool(false)); 390 scoped_ptr<bool> locked(new bool(false));
201 scoped_refptr<content::MessageLoopRunner> runner = 391 scoped_refptr<content::MessageLoopRunner> runner =
202 new content::MessageLoopRunner; 392 new content::MessageLoopRunner;
203 KioskAppManager::Get()->EnableConsumerModeKiosk( 393 KioskAppManager::Get()->EnableConsumerModeKiosk(
204 base::Bind(&ConsumerKioskModeLockCheck, 394 base::Bind(&ConsumerKioskModeLockCheck,
205 locked.get(), 395 locked.get(),
206 runner->QuitClosure())); 396 runner->QuitClosure()));
207 runner->Run(); 397 runner->Run();
208 EXPECT_TRUE(*locked.get()); 398 EXPECT_TRUE(*locked.get());
(...skipping 11 matching lines...) Expand all
220 runner->Run(); 410 runner->Run();
221 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1)); 411 CHECK_NE(status, static_cast<KioskAppManager::ConsumerKioskModeStatus>(-1));
222 return status; 412 return status;
223 } 413 }
224 414
225 content::WebUI* GetLoginUI() { 415 content::WebUI* GetLoginUI() {
226 return static_cast<chromeos::LoginDisplayHostImpl*>( 416 return static_cast<chromeos::LoginDisplayHostImpl*>(
227 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui(); 417 chromeos::LoginDisplayHostImpl::default_host())->GetOobeUI()->web_ui();
228 } 418 }
229 419
420 AppLaunchController* GetAppLaunchController() {
421 return chromeos::LoginDisplayHostImpl::default_host()
422 ->GetAppLaunchController();
423 }
424
230 std::string service_login_response_; 425 std::string service_login_response_;
231 scoped_ptr<EmbeddedTestServer> test_server_; 426 scoped_ptr<EmbeddedTestServer> test_server_;
427 scoped_ptr<net::NetworkChangeNotifier::DisableForTest>
428 disable_network_notifier_;
429 scoped_ptr<FakeNetworkChangeNotifier> fake_network_notifier_;
430 scoped_ptr<MockUserManager> mock_user_manager_;
232 }; 431 };
233 432
234 IN_PROC_BROWSER_TEST_P(KioskTest, InstallAndLaunchApp) { 433 IN_PROC_BROWSER_TEST_P(KioskTest, InstallAndLaunchApp) {
235 EnableConsumerKioskMode(); 434 StartAppLaunchFromLoginScreen(true);
236 chromeos::AppLaunchController::SkipSplashWaitForTesting(); 435 WaitForAppLaunchSuccess();
237 // Start UI, find menu entry for this app and launch it. 436 }
238 chromeos::WizardController::SkipPostLoginScreensForTesting();
239 chromeos::WizardController* wizard_controller =
240 chromeos::WizardController::default_controller();
241 CHECK(wizard_controller);
242 wizard_controller->SkipToLoginForTesting();
243 437
244 ReloadKioskApps(); 438 IN_PROC_BROWSER_TEST_P(KioskTest, LaunchAppNetworkDown) {
439 // Start app launch and wait for network connectivity timeout.
440 StartAppLaunchFromLoginScreen(false);
441 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
442 splash_waiter.Wait();
443 WaitForAppLaunchNetworkTimeout();
245 444
246 // Wait for the Kiosk App configuration to reload, then launch the app. 445 // Set up fake user manager with an owner for the test.
247 content::WindowedNotificationObserver( 446 mock_user_manager_->SetActiveUser(kTestOwnerEmail);
248 chrome::NOTIFICATION_KIOSK_APPS_LOADED, 447 AppLaunchController::SetUserManagerForTesting(mock_user_manager_.get());
249 content::NotificationService::AllSources()).Wait(); 448 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host())
250 GetLoginUI()->CallJavascriptFunction("login.AppsMenuButton.runAppForTesting", 449 ->GetOobeUI()->ShowOobeUI(false);
251 base::StringValue(kTestKioskApp));
252 450
253 // Wait for the Kiosk App to launch. 451 // Configure network should bring up lock screen for owner.
254 content::WindowedNotificationObserver( 452 OobeScreenWaiter lock_screen_waiter(OobeDisplay::SCREEN_ACCOUNT_PICKER);
255 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, 453 static_cast<AppLaunchSplashScreenActor::Delegate*>(GetAppLaunchController())
256 content::NotificationService::AllSources()).Wait(); 454 ->OnConfigureNetwork();
455 lock_screen_waiter.Wait();
257 456
258 // Check installer status. 457 // A network error screen should be shown after authenticating.
259 EXPECT_EQ(chromeos::KioskAppLaunchError::NONE, 458 content::WindowedNotificationObserver network_error_signal(
459 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN,
460 content::NotificationService::AllSources());
461 static_cast<AppLaunchSigninScreen::Delegate*>(GetAppLaunchController())
462 ->OnOwnerSigninSuccess();
463 network_error_signal.Wait();
464
465 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
466
467 WaitForAppLaunchSuccess();
468 }
469
470 IN_PROC_BROWSER_TEST_P(KioskTest, LaunchAppUserCancel) {
471 StartAppLaunchFromLoginScreen(false);
472 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
473 splash_waiter.Wait();
474
475 CrosSettings::Get()->SetBoolean(
476 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, true);
477 LOG(ERROR) << "BAILOUT!";
478 content::WindowedNotificationObserver signal(
479 chrome::NOTIFICATION_APP_TERMINATING,
480 content::NotificationService::AllSources());
481 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator",
482 base::StringValue("app_launch_bailout"));
483 signal.Wait();
484 EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL,
260 chromeos::KioskAppLaunchError::Get()); 485 chromeos::KioskAppLaunchError::Get());
261
262 // Check if the kiosk webapp is really installed for the default profile.
263 ASSERT_TRUE(ProfileManager::GetDefaultProfile());
264 const extensions::Extension* app =
265 extensions::ExtensionSystem::Get(ProfileManager::GetDefaultProfile())->
266 extension_service()->GetInstalledExtension(kTestKioskApp);
267 EXPECT_TRUE(app);
268
269 // Wait until the app terminates.
270 content::RunMessageLoop();
271 } 486 }
272 487
273 IN_PROC_BROWSER_TEST_P(KioskTest, AutolaunchWarningCancel) { 488 IN_PROC_BROWSER_TEST_P(KioskTest, AutolaunchWarningCancel) {
274 EnableConsumerKioskMode(); 489 EnableConsumerKioskMode();
275 // Start UI, find menu entry for this app and launch it. 490 // Start UI, find menu entry for this app and launch it.
276 chromeos::WizardController::SkipPostLoginScreensForTesting(); 491 chromeos::WizardController::SkipPostLoginScreensForTesting();
277 chromeos::WizardController* wizard_controller = 492 chromeos::WizardController* wizard_controller =
278 chromeos::WizardController::default_controller(); 493 chromeos::WizardController::default_controller();
279 CHECK(wizard_controller); 494 CHECK(wizard_controller);
280 ReloadAutolaunchKioskApps(); 495 ReloadAutolaunchKioskApps();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 content::WindowedNotificationObserver( 631 content::WindowedNotificationObserver(
417 chrome::NOTIFICATION_KIOSK_ENABLED, 632 chrome::NOTIFICATION_KIOSK_ENABLED,
418 content::NotificationService::AllSources()).Wait(); 633 content::NotificationService::AllSources()).Wait();
419 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED, 634 EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED,
420 GetConsumerKioskModeStatus()); 635 GetConsumerKioskModeStatus());
421 } 636 }
422 637
423 INSTANTIATE_TEST_CASE_P(KioskTestInstantiation, KioskTest, testing::Bool()); 638 INSTANTIATE_TEST_CASE_P(KioskTestInstantiation, KioskTest, testing::Bool());
424 639
425 } // namespace chromeos 640 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/app_launch_signin_screen.cc ('k') | chrome/browser/chromeos/login/login_display_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698