OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
6 #include "chrome/browser/chrome_notification_types.h" | |
7 #include "chrome/browser/extensions/extension_test_message_listener.h" | 6 #include "chrome/browser/extensions/extension_test_message_listener.h" |
8 #include "content/public/browser/notification_service.h" | 7 #include "content/public/browser/notification_service.h" |
9 #include "content/public/test/browser_test.h" | 8 #include "content/public/test/browser_test.h" |
10 #include "content/public/test/test_utils.h" | 9 #include "content/public/test/test_utils.h" |
| 10 #include "extensions/browser/notification_types.h" |
11 | 11 |
12 using extensions::Extension; | 12 using extensions::Extension; |
13 using extensions::PlatformAppBrowserTest; | 13 using extensions::PlatformAppBrowserTest; |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class AppEventPageTest : public PlatformAppBrowserTest { | 17 class AppEventPageTest : public PlatformAppBrowserTest { |
18 protected: | 18 protected: |
19 void TestUnloadEventPage(const char* app_path) { | 19 void TestUnloadEventPage(const char* app_path) { |
20 // Load and launch the app. | 20 // Load and launch the app. |
21 const Extension* extension = LoadAndLaunchPlatformApp(app_path, "launched"); | 21 const Extension* extension = LoadAndLaunchPlatformApp(app_path, "launched"); |
22 ASSERT_TRUE(extension); | 22 ASSERT_TRUE(extension); |
23 | 23 |
24 content::WindowedNotificationObserver event_page_suspended( | 24 content::WindowedNotificationObserver event_page_suspended( |
25 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 25 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
26 content::NotificationService::AllSources()); | 26 content::NotificationService::AllSources()); |
27 | 27 |
28 // Close the app window. | 28 // Close the app window. |
29 EXPECT_EQ(1U, GetAppWindowCount()); | 29 EXPECT_EQ(1U, GetAppWindowCount()); |
30 apps::AppWindow* app_window = GetFirstAppWindow(); | 30 apps::AppWindow* app_window = GetFirstAppWindow(); |
31 ASSERT_TRUE(app_window); | 31 ASSERT_TRUE(app_window); |
32 CloseAppWindow(app_window); | 32 CloseAppWindow(app_window); |
33 | 33 |
34 // Verify that the event page is destroyed. | 34 // Verify that the event page is destroyed. |
35 event_page_suspended.Wait(); | 35 event_page_suspended.Wait(); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 // Tests that an app's event page will eventually be unloaded. The onSuspend | 41 // Tests that an app's event page will eventually be unloaded. The onSuspend |
42 // event handler of this app does not make any API calls. | 42 // event handler of this app does not make any API calls. |
43 IN_PROC_BROWSER_TEST_F(AppEventPageTest, OnSuspendNoApiUse) { | 43 IN_PROC_BROWSER_TEST_F(AppEventPageTest, OnSuspendNoApiUse) { |
44 TestUnloadEventPage("event_page/suspend_simple"); | 44 TestUnloadEventPage("event_page/suspend_simple"); |
45 } | 45 } |
46 | 46 |
47 // Tests that an app's event page will eventually be unloaded. The onSuspend | 47 // Tests that an app's event page will eventually be unloaded. The onSuspend |
48 // event handler of this app calls a chrome.storage API function. | 48 // event handler of this app calls a chrome.storage API function. |
49 // See: http://crbug.com/296834 | 49 // See: http://crbug.com/296834 |
50 IN_PROC_BROWSER_TEST_F(AppEventPageTest, OnSuspendUseStorageApi) { | 50 IN_PROC_BROWSER_TEST_F(AppEventPageTest, OnSuspendUseStorageApi) { |
51 TestUnloadEventPage("event_page/suspend_storage_api"); | 51 TestUnloadEventPage("event_page/suspend_storage_api"); |
52 } | 52 } |
OLD | NEW |