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

Unified Diff: chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc

Issue 741473002: Revert of Fire notifications when reboot is requested, not scheduled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@managed_cros
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc
diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc b/chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc
index 059082ddec3cccf703c8b457caa82b36e54bb90a..970eeeb48c37a5ca48125cc766bd8576fa2060a8 100644
--- a/chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc
+++ b/chrome/browser/chromeos/app_mode/kiosk_app_update_service_browsertest.cc
@@ -14,7 +14,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
-#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_path_override.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -23,32 +22,26 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
-#include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_paths.h"
#include "chromeos/dbus/update_engine_client.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/test/test_utils.h"
#include "extensions/common/extension.h"
#include "extensions/test/extension_test_message_listener.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
-class KioskAppUpdateServiceTest
- : public extensions::PlatformAppBrowserTest,
- public system::AutomaticRebootManagerObserver {
+class KioskAppUpdateServiceTest : public extensions::PlatformAppBrowserTest {
public:
- KioskAppUpdateServiceTest()
- : app_(NULL),
- update_service_(NULL),
- automatic_reboot_manager_(NULL) {}
-
- ~KioskAppUpdateServiceTest() override {}
+ KioskAppUpdateServiceTest() : app_(NULL), update_service_(NULL) {}
+ virtual ~KioskAppUpdateServiceTest() {}
// extensions::PlatformAppBrowserTest overrides:
- void SetUpOnMainThread() override {
+ virtual void SetUpOnMainThread() override {
extensions::PlatformAppBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -72,26 +65,10 @@
command->AppendSwitch(switches::kForceAppMode);
command->AppendSwitchASCII(switches::kAppId, app_->id());
- automatic_reboot_manager_ =
- g_browser_process->platform_part()->automatic_reboot_manager();
- automatic_reboot_manager_->AddObserver(this);
- }
+ update_service_ = KioskAppUpdateServiceFactory::GetForProfile(profile());
+ update_service_->set_app_id(app_->id());
- // system::AutomaticRebootManagerObserver:
- void OnRebootRequested(
- system::AutomaticRebootManagerObserver::Reason) override {
- if (run_loop_)
- run_loop_->Quit();
- }
-
- void WillDestroyAutomaticRebootManager() override {
- automatic_reboot_manager_->RemoveObserver(this);
- }
-
- void CreateKioskAppUpdateService() {
- EXPECT_FALSE(update_service_);
- update_service_ = KioskAppUpdateServiceFactory::GetForProfile(profile());
- update_service_->Init(app_->id());
+ content::RunAllBlockingPoolTasksUntilIdle();
}
void FireAppUpdateAvailable() {
@@ -101,16 +78,8 @@
void FireUpdatedNeedReboot() {
UpdateEngineClient::Status status;
status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT;
- run_loop_.reset(new base::RunLoop);
- automatic_reboot_manager_->UpdateStatusChanged(status);
- run_loop_->Run();
- }
-
- void RequestPeriodicReboot() {
- run_loop_.reset(new base::RunLoop);
- g_browser_process->local_state()->SetInteger(
- prefs::kUptimeLimit, base::TimeDelta::FromMinutes(30).InSeconds());
- run_loop_->Run();
+ g_browser_process->platform_part()->automatic_reboot_manager()->
+ UpdateStatusChanged(status);
}
private:
@@ -118,63 +87,30 @@
scoped_ptr<base::ScopedPathOverride> uptime_file_override_;
const extensions::Extension* app_; // Not owned.
KioskAppUpdateService* update_service_; // Not owned.
- system::AutomaticRebootManager* automatic_reboot_manager_; // Not owned.
- scoped_ptr<base::RunLoop> run_loop_;
DISALLOW_COPY_AND_ASSIGN(KioskAppUpdateServiceTest);
};
-// Verifies that the app is notified a reboot is required when an app update
-// becomes available.
IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, AppUpdate) {
- CreateKioskAppUpdateService();
+ FireAppUpdateAvailable();
ExtensionTestMessageListener listener("app_update", false);
- FireAppUpdateAvailable();
listener.WaitUntilSatisfied();
}
-// Verifies that the app is notified a reboot is required when an OS update is
-// applied while Chrome is running and the policy to reboot after update is
-// enabled.
IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, OsUpdate) {
- CreateKioskAppUpdateService();
-
- g_browser_process->local_state()->SetBoolean(prefs::kRebootAfterUpdate, true);
- ExtensionTestMessageListener listener("os_update", false);
- FireUpdatedNeedReboot();
- listener.WaitUntilSatisfied();
-}
-
-// Verifies that the app is notified a reboot is required when a periodic reboot
-// is requested while Chrome is running.
-IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, Periodic) {
- CreateKioskAppUpdateService();
-
- ExtensionTestMessageListener listener("periodic", false);
- RequestPeriodicReboot();
- listener.WaitUntilSatisfied();
-}
-
-// Verifies that the app is notified a reboot is required when an OS update was
-// applied before Chrome was started and the policy to reboot after update is
-// enabled.
-IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, StartAfterOsUpdate) {
g_browser_process->local_state()->SetBoolean(prefs::kRebootAfterUpdate, true);
FireUpdatedNeedReboot();
ExtensionTestMessageListener listener("os_update", false);
- CreateKioskAppUpdateService();
listener.WaitUntilSatisfied();
}
-// Verifies that the app is notified a reboot is required when a periodic reboot
-// was requested before Chrome was started.
-IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, StartAfterPeriodic) {
- RequestPeriodicReboot();
+IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, Periodic) {
+ g_browser_process->local_state()->SetInteger(
+ prefs::kUptimeLimit, base::TimeDelta::FromMinutes(30).InSeconds());
ExtensionTestMessageListener listener("periodic", false);
- CreateKioskAppUpdateService();
listener.WaitUntilSatisfied();
}

Powered by Google App Engine
This is Rietveld 408576698