| OLD | NEW |
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
| 7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 ++iter) { | 99 ++iter) { |
| 100 ExtensionHost* host = *iter; | 100 ExtensionHost* host = *iter; |
| 101 if (host->extension() && host->extension()->is_platform_app()) | 101 if (host->extension() && host->extension()->is_platform_app()) |
| 102 return host->host_contents(); | 102 return host->host_contents(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 return NULL; | 105 return NULL; |
| 106 } | 106 } |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 // Disabled until shell windows are implemented for non-GTK toolkits. | 109 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. |
| 110 #if defined(TOOLKIT_GTK) | 110 #if defined(TOOLKIT_GTK) | defined(TOOLKIT_VIEWS) |
| 111 #define MAYBE_OpenAppInShellContainer OpenAppInShellContainer | 111 #define MAYBE_OpenAppInShellContainer OpenAppInShellContainer |
| 112 #else | 112 #else |
| 113 #define MAYBE_OpenAppInShellContainer DISABLED_OpenAppInShellContainer | 113 #define MAYBE_OpenAppInShellContainer DISABLED_OpenAppInShellContainer |
| 114 #endif | 114 #endif |
| 115 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_OpenAppInShellContainer) { | 115 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_OpenAppInShellContainer) { |
| 116 ASSERT_EQ(0u, GetPlatformAppCount()); | 116 ASSERT_EQ(0u, GetPlatformAppCount()); |
| 117 LoadAndLaunchPlatformApp("empty"); | 117 LoadAndLaunchPlatformApp("empty"); |
| 118 ASSERT_EQ(1u, GetPlatformAppCount()); | 118 ASSERT_EQ(1u, GetPlatformAppCount()); |
| 119 | 119 |
| 120 UnloadExtension(last_loaded_extension_id_); | 120 UnloadExtension(last_loaded_extension_id_); |
| 121 ASSERT_EQ(0u, GetPlatformAppCount()); | 121 ASSERT_EQ(0u, GetPlatformAppCount()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Disabled until shell windows are implemented for non-GTK toolkits. | 124 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. |
| 125 #if defined(TOOLKIT_GTK) | 125 #if defined(TOOLKIT_GTK) | defined(TOOLKIT_VIEWS) |
| 126 #define MAYBE_EmptyContextMenu EmptyContextMenu | 126 #define MAYBE_EmptyContextMenu EmptyContextMenu |
| 127 #else | 127 #else |
| 128 #define MAYBE_EmptyContextMenu DISABLED_EmptyContextMenu | 128 #define MAYBE_EmptyContextMenu DISABLED_EmptyContextMenu |
| 129 #endif | 129 #endif |
| 130 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_EmptyContextMenu) { | 130 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_EmptyContextMenu) { |
| 131 LoadAndLaunchPlatformApp("empty"); | 131 LoadAndLaunchPlatformApp("empty"); |
| 132 | 132 |
| 133 // The empty app doesn't add any context menu items, so its menu should | 133 // The empty app doesn't add any context menu items, so its menu should |
| 134 // be empty. | 134 // be empty. |
| 135 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 135 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 136 ASSERT_TRUE(web_contents); | 136 ASSERT_TRUE(web_contents); |
| 137 WebKit::WebContextMenuData data; | 137 WebKit::WebContextMenuData data; |
| 138 ContextMenuParams params(data); | 138 ContextMenuParams params(data); |
| 139 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, | 139 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
| 140 params); | 140 params); |
| 141 menu->Init(); | 141 menu->Init(); |
| 142 ASSERT_FALSE(menu->menu_model().GetItemCount()); | 142 ASSERT_FALSE(menu->menu_model().GetItemCount()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Disabled until shell windows are implemented for non-GTK toolkits. | 145 // Disabled until shell windows are implemented for non-GTK, non-Views toolkits. |
| 146 #if defined(TOOLKIT_GTK) | 146 #if defined(TOOLKIT_GTK) | defined(TOOLKIT_VIEWS) |
| 147 #define MAYBE_AppWithContextMenu AppWithContextMenu | 147 #define MAYBE_AppWithContextMenu AppWithContextMenu |
| 148 #else | 148 #else |
| 149 #define MAYBE_AppWithContextMenu DISABLED_AppWithContextMenu | 149 #define MAYBE_AppWithContextMenu DISABLED_AppWithContextMenu |
| 150 #endif | 150 #endif |
| 151 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWithContextMenu) { | 151 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_AppWithContextMenu) { |
| 152 ExtensionTestMessageListener listener1("created item", false); | 152 ExtensionTestMessageListener listener1("created item", false); |
| 153 LoadAndLaunchPlatformApp("context_menu"); | 153 LoadAndLaunchPlatformApp("context_menu"); |
| 154 | 154 |
| 155 // Wait for the extension to tell us it's created an item. | 155 // Wait for the extension to tell us it's created an item. |
| 156 ASSERT_TRUE(listener1.WaitUntilSatisfied()); | 156 ASSERT_TRUE(listener1.WaitUntilSatisfied()); |
| 157 | 157 |
| 158 // The context_menu app has one context menu item. This is all that should | 158 // The context_menu app has one context menu item. This is all that should |
| 159 // be in the menu, there should be no seperator. | 159 // be in the menu, there should be no seperator. |
| 160 WebContents* web_contents = GetFirstPlatformAppWebContents(); | 160 WebContents* web_contents = GetFirstPlatformAppWebContents(); |
| 161 ASSERT_TRUE(web_contents); | 161 ASSERT_TRUE(web_contents); |
| 162 WebKit::WebContextMenuData data; | 162 WebKit::WebContextMenuData data; |
| 163 ContextMenuParams params(data); | 163 ContextMenuParams params(data); |
| 164 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, | 164 PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
| 165 params); | 165 params); |
| 166 menu->Init(); | 166 menu->Init(); |
| 167 ASSERT_EQ(1, menu->menu_model().GetItemCount()); | 167 ASSERT_EQ(1, menu->menu_model().GetItemCount()); |
| 168 } | 168 } |
| OLD | NEW |