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..fb9bd38931f728fce6d5fb5358965050a787ac9e 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" |
| @@ -63,6 +65,33 @@ 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:: |
|
dcheng
2012/09/17 18:39:15
Nit: break the line after the ( instead and keep t
|
| + GetForProfile(browser()->profile()); |
| + ASSERT_TRUE(pss); |
| + |
| + // Construct a sync id for the object "U/<extension-id>/1". |
| + std::string id("U/"); |
| + id += extension->id(); |
| + id += "/1"; |
| + |
| + pss->SendInvalidationForTest(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) { |