Index: chrome/browser/extensions/platform_app_browsertest.cc |
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc |
index 41b5a5142dd0b85d09449a569b2e7abd36cc40c1..e3f823f1a77b7f34edaa3bb08fcbfdb5b1f5ed00 100644 |
--- a/chrome/browser/extensions/platform_app_browsertest.cc |
+++ b/chrome/browser/extensions/platform_app_browsertest.cc |
@@ -7,15 +7,15 @@ |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/extensions/extension_apitest.h" |
#include "chrome/browser/extensions/extension_browsertest.h" |
-#include "chrome/browser/extensions/extension_host.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_test_message_listener.h" |
+#include "chrome/browser/extensions/platform_app_registry.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/tab_contents/render_view_context_menu.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/browser/ui/extensions/shell_window.h" |
#include "chrome/common/chrome_switches.h" |
-#include "chrome/common/chrome_view_type.h" |
#include "chrome/common/extensions/extension_constants.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "content/public/browser/web_contents.h" |
@@ -55,7 +55,6 @@ class PlatformAppBrowserTest : public ExtensionApiTest { |
protected: |
void LoadAndLaunchPlatformApp(const char* name) { |
- size_t platform_app_count = GetPlatformAppCount(); |
ui_test_utils::WindowedNotificationObserver app_loaded_observer( |
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
content::NotificationService::AllSources()); |
@@ -76,40 +75,19 @@ class PlatformAppBrowserTest : public ExtensionApiTest { |
NEW_WINDOW); |
app_loaded_observer.Wait(); |
- |
- // Now we have a new platform app running. |
- EXPECT_EQ(platform_app_count + 1, GetPlatformAppCount()); |
benwells
2012/04/26 08:36:33
This check is no longer valid and I think was addi
|
- } |
- |
- // Gets the number of platform apps extension hosts that are running. |
- size_t GetPlatformAppCount() { |
- int count = 0; |
- ExtensionProcessManager* process_manager = |
- browser()->profile()->GetExtensionProcessManager(); |
- ExtensionProcessManager::const_iterator iter; |
- ExtensionProcessManager::ExtensionHostSet platform_app_hosts = |
- process_manager->platform_app_hosts(); |
- for (iter = platform_app_hosts.begin(); iter != platform_app_hosts.end(); |
- ++iter) { |
- if ((*iter)->extension()) |
- count++; |
- } |
- |
- return count; |
} |
- // Gets the WebContents associated with the ExtensionHost of the first |
- // platform app shell window that is found (most tests only deal with one |
- // platform app window, so this is good enough). |
- WebContents* GetFirstPlatformAppShellWindowWebContents() { |
- ExtensionProcessManager* process_manager = |
- browser()->profile()->GetExtensionProcessManager(); |
- ExtensionProcessManager::const_iterator iter; |
- ExtensionProcessManager::ExtensionHostSet platform_app_hosts = |
- process_manager->platform_app_hosts(); |
- for (iter = platform_app_hosts.begin(); iter != platform_app_hosts.end(); |
- ++iter) { |
- return (*iter)->host_contents(); |
+ // Gets the WebContents associated with the first shell window that is found |
+ // (most tests only deal with one platform app window, so this is good |
+ // enough). |
+ WebContents* GetFirstShellWindowWebContents() { |
+ PlatformAppRegistry* app_registry = |
+ PlatformAppRegistry::Get(browser()->profile()); |
+ PlatformAppRegistry::const_iterator iter; |
+ PlatformAppRegistry::ShellWindowSet shell_windows = |
+ app_registry->shell_windows(); |
+ for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter) { |
+ return (*iter)->web_contents(); |
} |
return NULL; |
@@ -129,13 +107,15 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) { |
// The empty app doesn't add any context menu items, so its menu should |
// only include the developer tools. |
- WebContents* web_contents = GetFirstPlatformAppShellWindowWebContents(); |
+ WebContents* web_contents = GetFirstShellWindowWebContents(); |
ASSERT_TRUE(web_contents); |
WebKit::WebContextMenuData data; |
content::ContextMenuParams params(data); |
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
params); |
menu->Init(); |
+ // TODO(benwells): Remove the constant below. Instead of checking the |
+ // number of menu items check certain item's absense and presence. |
// 3 including separator |
ASSERT_EQ(3, menu->menu_model().GetItemCount()); |
} |
@@ -150,13 +130,15 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) { |
// The context_menu app has one context menu item. This, along with a |
// separator and the developer tools, is all that should be in the menu. |
- WebContents* web_contents = GetFirstPlatformAppShellWindowWebContents(); |
+ WebContents* web_contents = GetFirstShellWindowWebContents(); |
ASSERT_TRUE(web_contents); |
WebKit::WebContextMenuData data; |
content::ContextMenuParams params(data); |
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents, |
params); |
menu->Init(); |
+ // TODO(benwells): Remove the constant below. Instead of checking the |
+ // number of menu items check certain item's absense and presence. |
ASSERT_EQ(4, menu->menu_model().GetItemCount()); |
} |