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

Side by Side Diff: chrome/browser/extensions/platform_app_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: Feedback 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 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/devtools/devtools_window.h" 11 #include "chrome/browser/devtools/devtools_window.h"
12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
13 #include "chrome/browser/extensions/app_restore_service_factory.h"
14 #include "chrome/browser/extensions/app_restore_service.h"
15 #include "chrome/browser/extensions/extension_browsertest.h" 13 #include "chrome/browser/extensions/extension_browsertest.h"
16 #include "chrome/browser/extensions/extension_prefs.h" 14 #include "chrome/browser/extensions/extension_prefs.h"
17 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/extension_test_message_listener.h" 17 #include "chrome/browser/extensions/extension_test_message_listener.h"
20 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
21 #include "chrome/browser/extensions/platform_app_launcher.h" 19 #include "chrome/browser/extensions/platform_app_launcher.h"
22 #include "chrome/browser/extensions/shell_window_registry.h" 20 #include "chrome/browser/extensions/shell_window_registry.h"
23 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
24 #include "chrome/browser/tab_contents/render_view_context_menu.h" 22 #include "chrome/browser/tab_contents/render_view_context_menu.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds()); 642 ASSERT_EQ(bounds, window->GetBaseWindow()->GetBounds());
645 643
646 // Tell javascript to open a second window. 644 // Tell javascript to open a second window.
647 page2_listener.Reply("continue"); 645 page2_listener.Reply("continue");
648 646
649 // Wait for javascript to verify that the second window got the updated 647 // Wait for javascript to verify that the second window got the updated
650 // coordinates, ignoring the default coordinates passed to the create method. 648 // coordinates, ignoring the default coordinates passed to the create method.
651 ASSERT_TRUE(done2_listener.WaitUntilSatisfied()); 649 ASSERT_TRUE(done2_listener.WaitUntilSatisfied());
652 } 650 }
653 651
654 // Tests that a running app is recorded in the preferences as such.
655 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, RunningAppsAreRecorded) {
656 content::WindowedNotificationObserver extension_suspended(
657 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
658 content::NotificationService::AllSources());
659
660 const Extension* extension = LoadExtension(
661 test_data_dir_.AppendASCII("platform_apps/restart_test"));
662 ASSERT_TRUE(extension);
663 ExtensionService* extension_service =
664 ExtensionSystem::Get(browser()->profile())->extension_service();
665 ExtensionPrefs* extension_prefs = extension_service->extension_prefs();
666
667 // App is running.
668 ASSERT_TRUE(extension_prefs->IsExtensionRunning(extension->id()));
669
670 // Wait for the extension to get suspended.
671 extension_suspended.Wait();
672
673 // App isn't running because it got suspended.
674 ASSERT_FALSE(extension_prefs->IsExtensionRunning(extension->id()));
675
676 // Pretend that the app is supposed to be running.
677 extension_prefs->SetExtensionRunning(extension->id(), true);
678
679 ExtensionTestMessageListener restart_listener("onRestarted", false);
680 AppRestoreServiceFactory::GetForProfile(browser()->profile())->
681 HandleStartup(true);
682 restart_listener.WaitUntilSatisfied();
683 }
684
685 namespace { 652 namespace {
686 653
687 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest { 654 class PlatformAppDevToolsBrowserTest : public PlatformAppBrowserTest {
688 protected: 655 protected:
689 enum TestFlags { 656 enum TestFlags {
690 RELAUNCH = 0x1, 657 RELAUNCH = 0x1,
691 HAS_ID = 0x2, 658 HAS_ID = 0x2,
692 }; 659 };
693 // Runs a test inside a harness that opens DevTools on a shell window. 660 // Runs a test inside a harness that opens DevTools on a shell window.
694 void RunTestWithDevTools(const char* name, int test_flags); 661 void RunTestWithDevTools(const char* name, int test_flags);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 891 }
925 892
926 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Messaging) { 893 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Messaging) {
927 ExtensionApiTest::ResultCatcher result_catcher; 894 ExtensionApiTest::ResultCatcher result_catcher;
928 LoadAndLaunchPlatformApp("messaging/app2"); 895 LoadAndLaunchPlatformApp("messaging/app2");
929 LoadAndLaunchPlatformApp("messaging/app1"); 896 LoadAndLaunchPlatformApp("messaging/app1");
930 EXPECT_TRUE(result_catcher.GetNextResult()); 897 EXPECT_TRUE(result_catcher.GetNextResult());
931 } 898 }
932 899
933 } // namespace extensions 900 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698