Chromium Code Reviews| Index: chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc |
| diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc |
| index 20c523b6883355207246aba27946034244706bbc..ee440d3950ce4ae005fbae93237f0b6b231a9eb6 100644 |
| --- a/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc |
| +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc |
| @@ -10,6 +10,8 @@ |
| #include "chrome/browser/extensions/extension_system.h" |
| #include "chrome/browser/extensions/extension_test_message_listener.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/sync/profile_sync_service.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| @@ -19,6 +21,10 @@ using ::testing::_; |
| using ::testing::SaveArg; |
| using ::testing::StrictMock; |
| +// TODO(dcheng): This is hardcoded for now since the svn export is not done yet. |
| +// Once it's done, use ipc::invalidation::ObjectSource::CHROME_PUSH_MESSAGING. |
| +const int kSourceId = 1030; |
| + |
| namespace extensions { |
| class MockInvalidationMapper : public PushMessagingInvalidationMapper { |
| @@ -63,6 +69,35 @@ IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, EventDispatch) { |
| EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| } |
| +// Test that a push introduced into the sync code makes it to the extension |
| +// that we install. |
| +IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, ReceivesPush) { |
| + ResultCatcher catcher; |
| + catcher.RestrictToProfile(browser()->profile()); |
| + ExtensionTestMessageListener ready("ready", true); |
| + |
| + const extensions::Extension* extension = |
| + LoadExtension(test_data_dir_.AppendASCII("push_messaging")); |
| + ASSERT_TRUE(extension); |
| + GURL page_url = extension->GetResourceURL("event_dispatch.html"); |
| + ui_test_utils::NavigateToURL(browser(), page_url); |
| + EXPECT_TRUE(ready.WaitUntilSatisfied()); |
| + |
| + ProfileSyncService* pss = ProfileSyncServiceFactory::GetForProfile( |
| + browser()->profile()); |
| + ASSERT_TRUE(pss); |
| + |
| + // Construct a sync id for the object "U/<extension-id>/1". |
| + std::string id("U/"); |
|
akalin
2012/09/18 00:12:33
can you just do:
const std::string id = "U/" + ex
dcheng
2012/09/20 20:44:19
+= is generally more efficient than + since it res
|
| + id += extension->id(); |
| + id += "/1"; |
| + |
| + invalidation::ObjectId object_id(kSourceId, id); |
| + |
| + pss->EmitInvalidationForTest(object_id, "payload"); |
| + EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| +} |
| + |
| // Checks that an extension with the pushMessaging permission gets automatically |
| // registered for invalidations when it is loaded. |
| IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, AutoRegistration) { |