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

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

Issue 494693003: Fix and re-enable KioskTest.LaunchAppWithNetworkConfigAccelerator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/app_window.h" 5 #include "apps/app_window.h"
6 #include "apps/app_window_registry.h" 6 #include "apps/app_window_registry.h"
7 #include "ash/desktop_background/desktop_background_controller.h" 7 #include "ash/desktop_background/desktop_background_controller.h"
8 #include "ash/desktop_background/desktop_background_controller_observer.h" 8 #include "ash/desktop_background/desktop_background_controller_observer.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
10 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/location.h"
14 #include "base/memory/scoped_ptr.h"
11 #include "base/path_service.h" 15 #include "base/path_service.h"
12 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
13 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/synchronization/lock.h"
15 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/app_mode/fake_cws.h" 22 #include "chrome/browser/chromeos/app_mode/fake_cws.h"
18 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" 23 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
19 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 24 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
20 #include "chrome/browser/chromeos/login/app_launch_controller.h" 25 #include "chrome/browser/chromeos/login/app_launch_controller.h"
21 #include "chrome/browser/chromeos/login/startup_utils.h" 26 #include "chrome/browser/chromeos/login/startup_utils.h"
22 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" 27 #include "chrome/browser/chromeos/login/test/app_window_waiter.h"
23 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" 28 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
24 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 29 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
(...skipping 10 matching lines...) Expand all
35 #include "chrome/browser/extensions/extension_test_message_listener.h" 40 #include "chrome/browser/extensions/extension_test_message_listener.h"
36 #include "chrome/browser/profiles/profile_impl.h" 41 #include "chrome/browser/profiles/profile_impl.h"
37 #include "chrome/browser/profiles/profiles_state.h" 42 #include "chrome/browser/profiles/profiles_state.h"
38 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" 43 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
39 #include "chrome/common/chrome_constants.h" 44 #include "chrome/common/chrome_constants.h"
40 #include "chrome/common/chrome_paths.h" 45 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/pref_names.h" 46 #include "chrome/common/pref_names.h"
42 #include "chromeos/chromeos_switches.h" 47 #include "chromeos/chromeos_switches.h"
43 #include "chromeos/dbus/cryptohome_client.h" 48 #include "chromeos/dbus/cryptohome_client.h"
44 #include "components/signin/core/common/signin_pref_names.h" 49 #include "components/signin/core/common/signin_pref_names.h"
50 #include "content/public/browser/browser_thread.h"
45 #include "content/public/browser/notification_observer.h" 51 #include "content/public/browser/notification_observer.h"
46 #include "content/public/browser/notification_registrar.h" 52 #include "content/public/browser/notification_registrar.h"
47 #include "content/public/browser/notification_service.h" 53 #include "content/public/browser/notification_service.h"
48 #include "content/public/test/browser_test_utils.h" 54 #include "content/public/test/browser_test_utils.h"
49 #include "extensions/browser/app_window/native_app_window.h" 55 #include "extensions/browser/app_window/native_app_window.h"
50 #include "extensions/browser/extension_system.h" 56 #include "extensions/browser/extension_system.h"
51 #include "google_apis/gaia/gaia_constants.h" 57 #include "google_apis/gaia/gaia_constants.h"
52 #include "google_apis/gaia/gaia_switches.h" 58 #include "google_apis/gaia/gaia_switches.h"
53 #include "google_apis/gaia/gaia_urls.h" 59 #include "google_apis/gaia/gaia_urls.h"
54 #include "net/test/embedded_test_server/embedded_test_server.h" 60 #include "net/test/embedded_test_server/embedded_test_server.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 LOG(INFO) << "kiosk locked = " << in_locked; 138 LOG(INFO) << "kiosk locked = " << in_locked;
133 *out_locked = in_locked; 139 *out_locked = in_locked;
134 runner_quit_task.Run(); 140 runner_quit_task.Run();
135 } 141 }
136 142
137 // Helper function for WaitForNetworkTimeOut. 143 // Helper function for WaitForNetworkTimeOut.
138 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) { 144 void OnNetworkWaitTimedOut(const base::Closure& runner_quit_task) {
139 runner_quit_task.Run(); 145 runner_quit_task.Run();
140 } 146 }
141 147
148 // Helper function for LockFileThread.
149 void LockAndUnlock(scoped_ptr<base::Lock> lock) {
150 lock->Acquire();
151 lock->Release();
152 }
153
142 // Helper functions for CanConfigureNetwork mock. 154 // Helper functions for CanConfigureNetwork mock.
143 class ScopedCanConfigureNetwork { 155 class ScopedCanConfigureNetwork {
144 public: 156 public:
145 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth) 157 ScopedCanConfigureNetwork(bool can_configure, bool needs_owner_auth)
146 : can_configure_(can_configure), 158 : can_configure_(can_configure),
147 needs_owner_auth_(needs_owner_auth), 159 needs_owner_auth_(needs_owner_auth),
148 can_configure_network_callback_( 160 can_configure_network_callback_(
149 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork, 161 base::Bind(&ScopedCanConfigureNetwork::CanConfigureNetwork,
150 base::Unretained(this))), 162 base::Unretained(this))),
151 needs_owner_auth_callback_(base::Bind( 163 needs_owner_auth_callback_(base::Bind(
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 510
499 SimulateNetworkOnline(); 511 SimulateNetworkOnline();
500 WaitForAppLaunchSuccess(); 512 WaitForAppLaunchSuccess();
501 } 513 }
502 514
503 AppLaunchController* GetAppLaunchController() { 515 AppLaunchController* GetAppLaunchController() {
504 return chromeos::LoginDisplayHostImpl::default_host() 516 return chromeos::LoginDisplayHostImpl::default_host()
505 ->GetAppLaunchController(); 517 ->GetAppLaunchController();
506 } 518 }
507 519
520 // Returns a lock that is holding a task on the FILE thread. Any tasks posted
521 // to the FILE thread after this call will be blocked until the returned
522 // lock is released.
523 // This can be used to prevent app installation from completing until some
524 // other conditions are checked and triggered. For example, this can be used
525 // to trigger the network screen during app launch without racing with the
526 // app launching process itself.
527 scoped_ptr<base::AutoLock> LockFileThread() {
528 scoped_ptr<base::Lock> lock(new base::Lock);
529 scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(*lock));
530 content::BrowserThread::PostTask(
531 content::BrowserThread::FILE, FROM_HERE,
532 base::Bind(&LockAndUnlock, base::Passed(&lock)));
533 return auto_lock.Pass();
534 }
535
508 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); } 536 MockUserManager* mock_user_manager() { return mock_user_manager_.get(); }
509 537
510 void set_test_app_id(const std::string& test_app_id) { 538 void set_test_app_id(const std::string& test_app_id) {
511 test_app_id_ = test_app_id; 539 test_app_id_ = test_app_id;
512 } 540 }
513 const std::string& test_app_id() const { return test_app_id_; } 541 const std::string& test_app_id() const { return test_app_id_; }
514 void set_test_app_version(const std::string& version) { 542 void set_test_app_version(const std::string& version) {
515 test_app_version_ = version; 543 test_app_version_ = version;
516 } 544 }
517 const std::string& test_app_version() const { return test_app_version_; } 545 const std::string& test_app_version() const { return test_app_version_; }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // Tests the network down case for the initial app download and launch. 580 // Tests the network down case for the initial app download and launch.
553 RunAppLaunchNetworkDownTest(); 581 RunAppLaunchNetworkDownTest();
554 } 582 }
555 583
556 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) { 584 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDown) {
557 // Tests the network down case for launching an existing app that is 585 // Tests the network down case for launching an existing app that is
558 // installed in PRE_LaunchAppNetworkDown. 586 // installed in PRE_LaunchAppNetworkDown.
559 RunAppLaunchNetworkDownTest(); 587 RunAppLaunchNetworkDownTest();
560 } 588 }
561 589
562 // TODO(zelidrag): Figure out why this test is flaky on bbots. 590 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppWithNetworkConfigAccelerator) {
563 IN_PROC_BROWSER_TEST_F(KioskTest,
564 DISABLED_LaunchAppWithNetworkConfigAccelerator) {
565 ScopedCanConfigureNetwork can_configure_network(true, false); 591 ScopedCanConfigureNetwork can_configure_network(true, false);
566 592
593 // Block app loading until the network screen is shown.
594 scoped_ptr<base::AutoLock> lock = LockFileThread();
595
567 // Start app launch and wait for network connectivity timeout. 596 // Start app launch and wait for network connectivity timeout.
568 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 597 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
569 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 598 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
570 splash_waiter.Wait(); 599 splash_waiter.Wait();
571 600
572 // A network error screen should be shown after authenticating. 601 // A network error screen should be shown after authenticating.
573 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE); 602 OobeScreenWaiter error_screen_waiter(OobeDisplay::SCREEN_ERROR_MESSAGE);
574 // Simulate Ctrl+Alt+N accelerator. 603 // Simulate Ctrl+Alt+N accelerator.
575 GetLoginUI()->CallJavascriptFunction( 604 GetLoginUI()->CallJavascriptFunction(
576 "cr.ui.Oobe.handleAccelerator", 605 "cr.ui.Oobe.handleAccelerator",
577 base::StringValue("app_launch_network_config")); 606 base::StringValue("app_launch_network_config"));
578 error_screen_waiter.Wait(); 607 error_screen_waiter.Wait();
579 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog()); 608 ASSERT_TRUE(GetAppLaunchController()->showing_network_dialog());
580 609
581 // Continue button should be visible since we are online. 610 // Continue button should be visible since we are online.
582 JsExpect("$('continue-network-config-btn').hidden == false"); 611 JsExpect("$('continue-network-config-btn').hidden == false");
583 612
584 // Click on [Continue] button. 613 // Click on [Continue] button.
585 ASSERT_TRUE(content::ExecuteScript( 614 ASSERT_TRUE(content::ExecuteScript(
586 GetLoginUI()->GetWebContents(), 615 GetLoginUI()->GetWebContents(),
587 "(function() {" 616 "(function() {"
588 "var e = new Event('click');" 617 "var e = new Event('click');"
589 "$('continue-network-config-btn').dispatchEvent(e);" 618 "$('continue-network-config-btn').dispatchEvent(e);"
590 "})();")); 619 "})();"));
591 620
621 // Let app launching resume.
622 lock.reset();
623
592 WaitForAppLaunchSuccess(); 624 WaitForAppLaunchSuccess();
593 } 625 }
594 626
595 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) { 627 IN_PROC_BROWSER_TEST_F(KioskTest, LaunchAppNetworkDownConfigureNotAllowed) {
596 // Mock network could not be configured. 628 // Mock network could not be configured.
597 ScopedCanConfigureNetwork can_configure_network(false, true); 629 ScopedCanConfigureNetwork can_configure_network(false, true);
598 630
599 // Start app launch and wait for network connectivity timeout. 631 // Start app launch and wait for network connectivity timeout.
600 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure()); 632 StartAppLaunchFromLoginScreen(SimulateNetworkOfflineClosure());
601 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH); 633 OobeScreenWaiter splash_waiter(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 content::WindowedNotificationObserver( 1404 content::WindowedNotificationObserver(
1373 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1405 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1374 content::NotificationService::AllSources()).Wait(); 1406 content::NotificationService::AllSources()).Wait();
1375 1407
1376 // Wait for the wallpaper to load. 1408 // Wait for the wallpaper to load.
1377 WaitForWallpaper(); 1409 WaitForWallpaper();
1378 EXPECT_TRUE(wallpaper_loaded()); 1410 EXPECT_TRUE(wallpaper_loaded());
1379 } 1411 }
1380 1412
1381 } // namespace chromeos 1413 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698