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

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

Issue 2495123003: Continue attempts to reinstall corrupt policy extensions across restarts (Closed)
Patch Set: merged latest from origin/master Created 4 years, 1 month 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
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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/common/wallpaper/wallpaper_controller.h" 8 #include "ash/common/wallpaper/wallpaper_controller.h"
9 #include "ash/common/wallpaper/wallpaper_controller_observer.h" 9 #include "ash/common/wallpaper/wallpaper_controller_observer.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/files/file_util.h"
14 #include "base/location.h" 13 #include "base/location.h"
15 #include "base/macros.h" 14 #include "base/macros.h"
16 #include "base/path_service.h" 15 #include "base/path_service.h"
17 #include "base/run_loop.h" 16 #include "base/run_loop.h"
18 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
20 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
21 #include "base/sys_info.h" 20 #include "base/sys_info.h"
22 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/chromeos/app_mode/fake_cws.h" 22 #include "chrome/browser/chromeos/app_mode/fake_cws.h"
(...skipping 11 matching lines...) Expand all
35 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 34 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
36 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 35 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
37 #include "chrome/browser/chromeos/login/wizard_controller.h" 36 #include "chrome/browser/chromeos/login/wizard_controller.h"
38 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" 37 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
39 #include "chrome/browser/chromeos/policy/device_local_account.h" 38 #include "chrome/browser/chromeos/policy/device_local_account.h"
40 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 39 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" 40 #include "chrome/browser/chromeos/profiles/profile_helper.h"
42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 41 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
43 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
44 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 43 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
44 #include "chrome/browser/extensions/browsertest_util.h"
45 #include "chrome/browser/extensions/extension_service.h" 45 #include "chrome/browser/extensions/extension_service.h"
46 #include "chrome/browser/extensions/updater/local_extension_cache.h"
47 #include "chrome/browser/profiles/profile_impl.h" 46 #include "chrome/browser/profiles/profile_impl.h"
48 #include "chrome/browser/profiles/profile_manager.h" 47 #include "chrome/browser/profiles/profile_manager.h"
49 #include "chrome/browser/profiles/profiles_state.h" 48 #include "chrome/browser/profiles/profiles_state.h"
50 #include "chrome/browser/signin/signin_manager_factory.h" 49 #include "chrome/browser/signin/signin_manager_factory.h"
51 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" 50 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
52 #include "chrome/common/chrome_constants.h" 51 #include "chrome/common/chrome_constants.h"
53 #include "chrome/common/chrome_paths.h" 52 #include "chrome/common/chrome_paths.h"
54 #include "chrome/common/pref_names.h" 53 #include "chrome/common/pref_names.h"
55 #include "chromeos/chromeos_paths.h"
56 #include "chromeos/chromeos_switches.h" 54 #include "chromeos/chromeos_switches.h"
57 #include "chromeos/dbus/cryptohome_client.h" 55 #include "chromeos/dbus/cryptohome_client.h"
58 #include "chromeos/disks/disk_mount_manager.h" 56 #include "chromeos/disks/disk_mount_manager.h"
59 #include "chromeos/settings/cros_settings_provider.h" 57 #include "chromeos/settings/cros_settings_provider.h"
60 #include "components/prefs/pref_service.h" 58 #include "components/prefs/pref_service.h"
61 #include "components/signin/core/browser/signin_manager.h" 59 #include "components/signin/core/browser/signin_manager.h"
62 #include "components/signin/core/common/signin_pref_names.h" 60 #include "components/signin/core/common/signin_pref_names.h"
63 #include "content/public/browser/browser_thread.h" 61 #include "content/public/browser/browser_thread.h"
64 #include "content/public/browser/notification_observer.h" 62 #include "content/public/browser/notification_observer.h"
65 #include "content/public/browser/notification_registrar.h" 63 #include "content/public/browser/notification_registrar.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 void SetUpOnMainThread() override { 517 void SetUpOnMainThread() override {
520 OobeBaseTest::SetUpOnMainThread(); 518 OobeBaseTest::SetUpOnMainThread();
521 // Needed to avoid showing Gaia screen instead of owner signin for 519 // Needed to avoid showing Gaia screen instead of owner signin for
522 // consumer network down test cases. 520 // consumer network down test cases.
523 StartupUtils::MarkDeviceRegistered(base::Closure()); 521 StartupUtils::MarkDeviceRegistered(base::Closure());
524 settings_helper_.ReplaceProvider(kAccountsPrefDeviceLocalAccounts); 522 settings_helper_.ReplaceProvider(kAccountsPrefDeviceLocalAccounts);
525 owner_settings_service_ = settings_helper_.CreateOwnerSettingsService( 523 owner_settings_service_ = settings_helper_.CreateOwnerSettingsService(
526 ProfileManager::GetPrimaryUserProfile()); 524 ProfileManager::GetPrimaryUserProfile());
527 525
528 // Set up local cache for app update check. 526 // Set up local cache for app update check.
529 CreateAndInitializeLocalCache(); 527 extensions::browsertest_util::CreateAndInitializeLocalCache();
530 } 528 }
531 529
532 void TearDownOnMainThread() override { 530 void TearDownOnMainThread() override {
533 settings_helper_.RestoreProvider(); 531 settings_helper_.RestoreProvider();
534 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); 532 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
535 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); 533 AppLaunchSigninScreen::SetUserManagerForTesting(NULL);
536 534
537 OobeBaseTest::TearDownOnMainThread(); 535 OobeBaseTest::TearDownOnMainThread();
538 536
539 // Clean up while main thread still runs. 537 // Clean up while main thread still runs.
540 // See http://crbug.com/176659. 538 // See http://crbug.com/176659.
541 KioskAppManager::Get()->CleanUp(); 539 KioskAppManager::Get()->CleanUp();
542 } 540 }
543 541
544 // The local cache is supposed to be initialized on chromeos device, and a
545 // ready flag file will be pre-created to mark the ready state, before chrome
546 // starts. In order for the tests to run without being on real chromeos
547 // device, we need to manually create this file.
548 void CreateAndInitializeLocalCache() {
549 base::FilePath extension_cache_dir;
550 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE,
551 &extension_cache_dir));
552 base::FilePath cache_init_file = extension_cache_dir.Append(
553 extensions::LocalExtensionCache::kCacheReadyFlagFileName);
554 EXPECT_EQ(base::WriteFile(cache_init_file, "", 0), 0);
555 }
556
557 void SetUpCommandLine(base::CommandLine* command_line) override { 542 void SetUpCommandLine(base::CommandLine* command_line) override {
558 OobeBaseTest::SetUpCommandLine(command_line); 543 OobeBaseTest::SetUpCommandLine(command_line);
559 fake_cws_->Init(embedded_test_server()); 544 fake_cws_->Init(embedded_test_server());
560 } 545 }
561 546
562 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 547 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
563 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI(); 548 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
564 GetLoginUI()->CallJavascriptFunctionUnsafe( 549 GetLoginUI()->CallJavascriptFunctionUnsafe(
565 new_kiosk_ui ? kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 550 new_kiosk_ui ? kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
566 base::StringValue(app_id), base::FundamentalValue(diagnostic_mode)); 551 base::StringValue(app_id), base::FundamentalValue(diagnostic_mode));
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 // ash::WallpaperControllerObserver overrides: 2352 // ash::WallpaperControllerObserver overrides:
2368 void OnWallpaperDataChanged() override { 2353 void OnWallpaperDataChanged() override {
2369 wallpaper_loaded_ = true; 2354 wallpaper_loaded_ = true;
2370 if (runner_.get()) 2355 if (runner_.get())
2371 runner_->Quit(); 2356 runner_->Quit();
2372 } 2357 }
2373 2358
2374 bool wallpaper_loaded_; 2359 bool wallpaper_loaded_;
2375 scoped_refptr<content::MessageLoopRunner> runner_; 2360 scoped_refptr<content::MessageLoopRunner> runner_;
2376 2361
2362 private:
2377 DISALLOW_COPY_AND_ASSIGN(KioskHiddenWebUITest); 2363 DISALLOW_COPY_AND_ASSIGN(KioskHiddenWebUITest);
2378 }; 2364 };
2379 2365
2380 IN_PROC_BROWSER_TEST_F(KioskHiddenWebUITest, AutolaunchWarning) { 2366 IN_PROC_BROWSER_TEST_F(KioskHiddenWebUITest, AutolaunchWarning) {
2381 // Add a device owner. 2367 // Add a device owner.
2382 FakeChromeUserManager* user_manager = new FakeChromeUserManager(); 2368 FakeChromeUserManager* user_manager = new FakeChromeUserManager();
2383 user_manager->AddUser(test_owner_account_id_); 2369 user_manager->AddUser(test_owner_account_id_);
2384 ScopedUserManagerEnabler enabler(user_manager); 2370 ScopedUserManagerEnabler enabler(user_manager);
2385 2371
2386 // Set kiosk app to autolaunch. 2372 // Set kiosk app to autolaunch.
(...skipping 15 matching lines...) Expand all
2402 content::WindowedNotificationObserver( 2388 content::WindowedNotificationObserver(
2403 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 2389 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
2404 content::NotificationService::AllSources()).Wait(); 2390 content::NotificationService::AllSources()).Wait();
2405 2391
2406 // Wait for the wallpaper to load. 2392 // Wait for the wallpaper to load.
2407 WaitForWallpaper(); 2393 WaitForWallpaper();
2408 EXPECT_TRUE(wallpaper_loaded()); 2394 EXPECT_TRUE(wallpaper_loaded());
2409 } 2395 }
2410 2396
2411 } // namespace chromeos 2397 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/kiosk_crash_restore_browsertest.cc ('k') | chrome/browser/extensions/browsertest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698