| Index: chrome/browser/task_manager/task_manager_browsertest.cc
|
| diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
|
| index b16d24528be3f32b8964d25f4f35190ffe00155d..b7accb04580ef7c7e423307ed8e10a82a8c37503 100644
|
| --- a/chrome/browser/task_manager/task_manager_browsertest.cc
|
| +++ b/chrome/browser/task_manager/task_manager_browsertest.cc
|
| @@ -13,6 +13,9 @@
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/extensions/extension_browsertest.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| +#include "chrome/browser/extensions/extension_test_message_listener.h"
|
| +#include "chrome/browser/extensions/platform_app_launcher.h"
|
| +#include "chrome/browser/extensions/platform_app_browsertest_util.h"
|
| #include "chrome/browser/infobars/infobar_tab_helper.h"
|
| #include "chrome/browser/notifications/desktop_notification_service.h"
|
| #include "chrome/browser/notifications/notification.h"
|
| @@ -74,6 +77,15 @@ class TaskManagerBrowserTest : public ExtensionBrowserTest {
|
| command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
|
| command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
|
| }
|
| +
|
| + int GetResourceCountAfterLoad() {
|
| + // Show the task manager. This populates the model, and helps with debugging
|
| + // (you see the task manager).
|
| + browser()->window()->ShowTaskManager();
|
| + // Wait for loading of task manager.
|
| + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
|
| + return TaskManager::GetInstance()->model()->ResourceCount();
|
| + }
|
| };
|
|
|
| #if defined(OS_MACOSX) || defined(OS_LINUX)
|
| @@ -361,6 +373,76 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) {
|
| TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
|
| }
|
|
|
| +namespace {
|
| + class PlatformAppTestContext : public extensions::PlatformAppBrowserTest {
|
| + public:
|
| + PlatformAppTestContext(Browser* browser, NotificationObserver* observer,
|
| + FilePath test_data_dir)
|
| + : browser_(browser), observer_(observer),
|
| + test_data_dir_(test_data_dir) {
|
| + }
|
| + virtual void TestBody() {}
|
| + virtual void RunTestOnMainThread() {}
|
| + const extensions::Extension* Launch(const char* name) {
|
| + return LoadAndLaunchPlatformApp(
|
| + browser_, observer_, test_data_dir_, name);
|
| + }
|
| + private:
|
| + Browser* browser_;
|
| + NotificationObserver* observer_;
|
| + FilePath test_data_dir_;
|
| + };
|
| +} // namespace
|
| +
|
| +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePlatformAppTabs) {
|
| + int resource_count = GetResourceCountAfterLoad();
|
| +
|
| + PlatformAppTestContext platform_app_test_context(
|
| + browser(), this, test_data_dir_);
|
| + ExtensionTestMessageListener launched_listener("Launched", false);
|
| + const extensions::Extension* extension =
|
| + platform_app_test_context.Launch("minimal");
|
| + (void)extension;
|
| +
|
| + ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
|
| +
|
| + TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
|
| + string16 prefix;
|
| +
|
| +
|
| + // First new entry should be the background page. The title should start with
|
| + // "Background Page:".
|
| + ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(
|
| + resource_count));
|
| +
|
| + // TODO(tapted) Can we get the background page when not loaded via
|
| + // TabContents?
|
| + // ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL);
|
| + // ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension);
|
| +
|
| + prefix = l10n_util::GetStringFUTF16(
|
| + IDS_TASK_MANAGER_BACKGROUND_PREFIX, string16());
|
| + ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
|
| + prefix, true));
|
| +
|
| + ++resource_count;
|
| + // Second new entry should be the App Window background page. The title should
|
| + // start with "Background Page:".
|
| + ASSERT_EQ(TaskManager::Resource::EXTENSION, model()->GetResourceType(
|
| + resource_count));
|
| + // ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL);
|
| + // ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension);
|
| +
|
| + prefix = l10n_util::GetStringFUTF16(
|
| + IDS_TASK_MANAGER_APP_PREFIX, string16());
|
| + ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
|
| + prefix, true));
|
| +
|
| + // Unload extension to avoid crash on Windows.
|
| + UnloadExtension(last_loaded_extension_id_);
|
| + TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
|
| +}
|
| +
|
| IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) {
|
| // Show the task manager. This populates the model, and helps with debugging
|
| // (you see the task manager).
|
|
|