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..bbb12b2032a419c4925b9ca0c172c4a50fdbc049 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,38 @@ 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 |
|
Mihai Parparita -not on Chrome
2012/09/13 20:37:09
Nit: capitalize sentence, end it with a period.
(
Pete Williamson
2012/09/14 19:14:48
Done.
|
| +// that we install |
| +IN_PROC_BROWSER_TEST_F(PushMessagingApiTest, receivesPush) { |
| + ResultCatcher catcher; |
| + catcher.RestrictToProfile(browser()->profile()); |
| + ExtensionTestMessageListener ready("ready", true); |
| + |
| + // launch the test app |
|
dcheng
2012/09/13 21:00:48
In general, comments like this aren't needed. Ditt
Pete Williamson
2012/09/14 19:14:48
Done.
|
| + 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()); |
| + |
| + // get the profile sync service to use |
| + ProfileSyncService* pss = ProfileSyncServiceFactory:: |
| + GetForProfile(browser()->profile()); |
| + ASSERT_TRUE(NULL != pss); |
|
dcheng
2012/09/13 21:00:48
ASSERT_TRUE(pss) to match style in other parts of
Pete Williamson
2012/09/14 19:14:48
Done.
|
| + |
| + // construct a sync id for the object "U/<extension-id>/1" |
| + std::string id("U/"); |
| + id += extension->id(); |
| + id += "/1"; |
| + |
| + // now send the notification via the profile sync service |
| + pss->SendNotificationForTest(id, "payload"); |
| + |
| + // verify that the test app sees a push message |
| + 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) { |