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

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc

Issue 10920084: don't display platform app resources in normal browser windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forgot to add Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
6 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h" 6 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h"
7 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_mapper.h" 7 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_mapper.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/platform_app_launcher.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
14 #include "chrome/browser/sync/profile_sync_service_factory.h" 15 #include "chrome/browser/sync/profile_sync_service_factory.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 20
20 using ::testing::_; 21 using ::testing::_;
21 using ::testing::SaveArg; 22 using ::testing::SaveArg;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 }; 54 };
54 55
55 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) { 56 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) {
56 ResultCatcher catcher; 57 ResultCatcher catcher;
57 catcher.RestrictToProfile(browser()->profile()); 58 catcher.RestrictToProfile(browser()->profile());
58 59
59 ExtensionTestMessageListener ready("ready", true); 60 ExtensionTestMessageListener ready("ready", true);
60 const extensions::Extension* extension = 61 const extensions::Extension* extension =
61 LoadExtension(test_data_dir_.AppendASCII("push_messaging")); 62 LoadExtension(test_data_dir_.AppendASCII("push_messaging"));
62 ASSERT_TRUE(extension); 63 ASSERT_TRUE(extension);
63 GURL page_url = extension->GetResourceURL("event_dispatch.html"); 64 extensions::LaunchPlatformApp(
64 ui_test_utils::NavigateToURL(browser(), page_url); 65 browser()->profile(), extension, NULL, FilePath());
65 EXPECT_TRUE(ready.WaitUntilSatisfied()); 66 EXPECT_TRUE(ready.WaitUntilSatisfied());
66 67
67 GetEventRouter()->TriggerMessageForTest(extension->id(), 1, "payload"); 68 GetEventRouter()->TriggerMessageForTest(extension->id(), 1, "payload");
68 69
69 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 70 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
70 } 71 }
71 72
72 // Test that a push introduced into the sync code makes it to the extension 73 // Test that a push introduced into the sync code makes it to the extension
73 // that we install. 74 // that we install.
74 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, ReceivesPush) { 75 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, ReceivesPush) {
75 ResultCatcher catcher; 76 ResultCatcher catcher;
76 catcher.RestrictToProfile(browser()->profile()); 77 catcher.RestrictToProfile(browser()->profile());
77 ExtensionTestMessageListener ready("ready", true); 78 ExtensionTestMessageListener ready("ready", true);
78 79
79 const extensions::Extension* extension = 80 const extensions::Extension* extension =
80 LoadExtension(test_data_dir_.AppendASCII("push_messaging")); 81 LoadExtension(test_data_dir_.AppendASCII("push_messaging"));
81 ASSERT_TRUE(extension); 82 ASSERT_TRUE(extension);
82 GURL page_url = extension->GetResourceURL("event_dispatch.html"); 83 extensions::LaunchPlatformApp(
83 ui_test_utils::NavigateToURL(browser(), page_url); 84 browser()->profile(), extension, NULL, FilePath());
84 EXPECT_TRUE(ready.WaitUntilSatisfied()); 85 EXPECT_TRUE(ready.WaitUntilSatisfied());
85 86
86 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile( 87 ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile(
87 browser()->profile()); 88 browser()->profile());
88 ASSERT_TRUE(pss); 89 ASSERT_TRUE(pss);
89 90
90 // Construct a sync id for the object "U/<extension-id>/1". 91 // Construct a sync id for the object "U/<extension-id>/1".
91 std::string id = "U/"; 92 std::string id = "U/";
92 id += extension->id(); 93 id += extension->id();
93 id += "/1"; 94 id += "/1";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_EQ(1U, handler->GetRegisteredExtensionsForTest().size()); 138 EXPECT_EQ(1U, handler->GetRegisteredExtensionsForTest().size());
138 } 139 }
139 140
140 // Test the GetChannelId API. 141 // Test the GetChannelId API.
141 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, GetChannelId) { 142 IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, GetChannelId) {
142 ResultCatcher catcher; 143 ResultCatcher catcher;
143 catcher.RestrictToProfile(browser()->profile()); 144 catcher.RestrictToProfile(browser()->profile());
144 145
145 ExtensionTestMessageListener ready("ready", true); 146 ExtensionTestMessageListener ready("ready", true);
146 const extensions::Extension* extension = 147 const extensions::Extension* extension =
147 LoadExtension(test_data_dir_.AppendASCII("push_messaging")); 148 LoadExtension(test_data_dir_.AppendASCII("get_channel_id"));
148 ASSERT_TRUE(extension); 149 ASSERT_TRUE(extension);
149 GURL page_url = extension->GetResourceURL("get_channel_id.html"); 150 extensions::LaunchPlatformApp(
150 ui_test_utils::NavigateToURL(browser(), page_url); 151 browser()->profile(), extension, NULL, FilePath());
151 152
152 // Just loading the page will cause a getChannelId call, so we check 153 // Just loading the page will cause a getChannelId call, so we check
153 // for a callback. It should fail because there is no auth token. 154 // for a callback. It should fail because there is no auth token.
154 155
155 // Make sure we got a failure (but we do get a result). 156 // Make sure we got a failure (but we do get a result).
156 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 157 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
157 } 158 }
158 159
159 } // namespace extensions 160 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698