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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10875027: Restart running apps when chrome restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/automation/automation_util.h" 10 #include "chrome/browser/automation/automation_util.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h" 11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/extensions/app_restore_service_factory.h"
13 #include "chrome/browser/extensions/app_restore_service.h"
12 #include "chrome/browser/extensions/extension_browsertest.h" 14 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/extensions/extension_prefs.h"
16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/extensions/extension_test_message_listener.h" 18 #include "chrome/browser/extensions/extension_test_message_listener.h"
14 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
15 #include "chrome/browser/extensions/platform_app_launcher.h" 20 #include "chrome/browser/extensions/platform_app_launcher.h"
16 #include "chrome/browser/extensions/shell_window_registry.h" 21 #include "chrome/browser/extensions/shell_window_registry.h"
17 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 23 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/extensions/application_launch.h" 24 #include "chrome/browser/ui/extensions/application_launch.h"
20 #include "chrome/browser/ui/extensions/shell_window.h" 25 #include "chrome/browser/ui/extensions/shell_window.h"
21 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/test/base/ui_test_utils.h" 27 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/web_intents_dispatcher.h" 29 #include "content/public/browser/web_intents_dispatcher.h"
30 #include "content/public/test/test_utils.h"
25 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
26 #include "webkit/glue/web_intent_data.h" 32 #include "webkit/glue/web_intent_data.h"
27 33
28 using content::WebContents; 34 using content::WebContents;
29 35
30 namespace extensions { 36 namespace extensions {
31 37
32 namespace { 38 namespace {
33 39
34 // Non-abstract RenderViewContextMenu class. 40 // Non-abstract RenderViewContextMenu class.
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); 604 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
599 605
600 // Tell javascript to open a third window. 606 // Tell javascript to open a third window.
601 page3_listener.Reply("continue"); 607 page3_listener.Reply("continue");
602 608
603 // Wait for javascript to verify that the third window got the restored size 609 // Wait for javascript to verify that the third window got the restored size
604 // and explicitly specified coordinates. 610 // and explicitly specified coordinates.
605 ASSERT_TRUE(done3_listener.WaitUntilSatisfied()); 611 ASSERT_TRUE(done3_listener.WaitUntilSatisfied());
606 } 612 }
607 613
614 // Tests that a running app is recorded in the preferences as such.
615 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
616 content::WindowedNotificationObserver extension_suspended(
617 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
618 content::NotificationService::AllSources());
619
620 const Extension* extension = LoadExtension(
621 test_data_dir_.AppendASCII("platform_apps/restart_test"));
622 ASSERT_TRUE(extension);
623 ExtensionService* extension_service =
624 ExtensionSystem::Get(browser()->profile())->extension_service();
625 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
626
627 // App is running.
628 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id()));
629
630 // Wait for the extension to get suspended.
631 extension_suspended.Wait();
632
633 // App isn't running because it got suspended.
634 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
635
636 // Pretend that the app is supposed to be running.
637 extension_prefs->SetExtensionRunning(extension->id(), true);
638
639 ExtensionTestMessageListener restart_listener("onRestarted", false);
640 AppRestoreServiceFactory::GetForProfile(browser()->profile())->RestoreApps();
641 restart_listener.WaitUntilSatisfied();
642 }
643
608 } // namespace extensions 644 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/platform_app_browsertest_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698