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

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10119003: Pull shell window stuff out of ExtensionHost and put in ShellWindow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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());
}

Powered by Google App Engine
This is Rietveld 408576698