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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed 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 unified diff | Download patch
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/stringprintf.h" 6 #include "base/stringprintf.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Now we have a new platform app running. 80 // Now we have a new platform app running.
81 EXPECT_EQ(platform_app_count + 1, GetPlatformAppCount()); 81 EXPECT_EQ(platform_app_count + 1, GetPlatformAppCount());
82 } 82 }
83 83
84 // Gets the number of platform apps extension hosts that are running. 84 // Gets the number of platform apps extension hosts that are running.
85 size_t GetPlatformAppCount() { 85 size_t GetPlatformAppCount() {
86 int count = 0; 86 int count = 0;
87 ExtensionProcessManager* process_manager = 87 ExtensionProcessManager* process_manager =
88 browser()->profile()->GetExtensionProcessManager(); 88 browser()->profile()->GetExtensionProcessManager();
89 ExtensionProcessManager::const_iterator iter; 89 ExtensionProcessManager::const_iterator iter;
90 for (iter = process_manager->begin(); iter != process_manager->end(); 90 ExtensionProcessManager::ExtensionHostSet platform_app_hosts =
91 process_manager->platform_app_hosts();
92 for (iter = platform_app_hosts.begin(); iter != platform_app_hosts.end();
91 ++iter) { 93 ++iter) {
92 ExtensionHost* host = *iter; 94 if ((*iter)->extension())
93 if (host->extension() && host->extension()->is_platform_app())
94 count++; 95 count++;
95 } 96 }
96 97
97 return count; 98 return count;
98 } 99 }
99 100
100 // Gets the WebContents associated with the ExtensionHost of the first 101 // Gets the WebContents associated with the ExtensionHost of the first
101 // platform app shell window that is found (most tests only deal with one 102 // platform app shell window that is found (most tests only deal with one
102 // platform app window, so this is good enough). 103 // platform app window, so this is good enough).
103 WebContents* GetFirstPlatformAppShellWindowWebContents() { 104 WebContents* GetFirstPlatformAppShellWindowWebContents() {
104 ExtensionProcessManager* process_manager = 105 ExtensionProcessManager* process_manager =
105 browser()->profile()->GetExtensionProcessManager(); 106 browser()->profile()->GetExtensionProcessManager();
106 ExtensionProcessManager::const_iterator iter; 107 ExtensionProcessManager::const_iterator iter;
107 for (iter = process_manager->begin(); iter != process_manager->end(); 108 ExtensionProcessManager::ExtensionHostSet platform_app_hosts =
109 process_manager->platform_app_hosts();
110 for (iter = platform_app_hosts.begin(); iter != platform_app_hosts.end();
108 ++iter) { 111 ++iter) {
109 ExtensionHost* host = *iter; 112 return (*iter)->host_contents();
110 if (host->extension() && host->extension()->is_platform_app() &&
111 host->extension_host_type() == chrome::VIEW_TYPE_APP_SHELL)
112 return host->host_contents();
113 } 113 }
114 114
115 return NULL; 115 return NULL;
116 } 116 }
117 }; 117 };
118 118
119 // Tests that platform apps received the "launch" event when launched. 119 // Tests that platform apps received the "launch" event when launched.
120 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) { 120 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
121 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_; 121 ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
122 } 122 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) { 173 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, Restrictions) {
174 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_; 174 ASSERT_TRUE(RunPlatformAppTest("platform_apps/restrictions")) << message_;
175 } 175 }
176 176
177 // Tests that platform apps can use the chrome.windows.* API. 177 // Tests that platform apps can use the chrome.windows.* API.
178 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApi) { 178 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApi) {
179 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_; 179 ASSERT_TRUE(RunPlatformAppTest("platform_apps/windows_api")) << message_;
180 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698