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

Unified Diff: apps/app_restore_service_browsertest.cc

Issue 11829055: Create top level apps component and move some apps code there. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved test, c/b/e not allowed to use apps Created 7 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 side-by-side diff with in-line comments
Download patch
Index: apps/app_restore_service_browsertest.cc
diff --git a/apps/app_restore_service_browsertest.cc b/apps/app_restore_service_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f2e47a92d3de5a4255e2b4a6a8e5ab8a35958e3c
--- /dev/null
+++ b/apps/app_restore_service_browsertest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "apps/app_restore_service.h"
+#include "apps/app_restore_service_factory.h"
+#include "chrome/browser/extensions/extension_prefs.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_test_message_listener.h"
+#include "chrome/browser/extensions/platform_app_browsertest_util.h"
+#include "chrome/common/extensions/extension.h"
+#include "content/public/test/test_utils.h"
+
+using extensions::Extension;
+using extensions::ExtensionPrefs;
+using extensions::ExtensionSystem;
+// TODO(benwells): Move PlatformAppBrowserTest to apps namespace in apps
+// component.
+using extensions::PlatformAppBrowserTest;
+
+namespace apps {
+
+// Tests that a running app is recorded in the preferences as such.
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
+ content::WindowedNotificationObserver extension_suspended(
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
+ content::NotificationService::AllSources());
+
+ const Extension* extension = LoadExtension(
+ test_data_dir_.AppendASCII("platform_apps/restart_test"));
+ ASSERT_TRUE(extension);
+ ExtensionService* extension_service =
+ ExtensionSystem::Get(browser()->profile())->extension_service();
+ ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
+
+ // App is running.
+ ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id()));
+
+ // Wait for the extension to get suspended.
+ extension_suspended.Wait();
+
+ // App isn't running because it got suspended.
+ ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
+
+ // Pretend that the app is supposed to be running.
+ extension_prefs->SetExtensionRunning(extension->id(), true);
+
+ ExtensionTestMessageListener restart_listener("onRestarted", false);
+ apps::AppRestoreServiceFactory::GetForProfile(browser()->profile())->
+ HandleStartup(true);
+ restart_listener.WaitUntilSatisfied();
+}
+
+} // apps

Powered by Google App Engine
This is Rietveld 408576698