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

Unified Diff: chrome/browser/extensions/api/push_messaging/push_messaging_apitest.cc

Issue 10915216: Browser test for the push messaging feature (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Change name of obj_id variable Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
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..5362ef39577efad341423377d253e03c6097cb00 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/");
+ id += extension->id();
+ id += "/1";
+
+ invalidation::ObjectId object_id(kSourceId, id);
+
+ pss->SendInvalidationForTest(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) {
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.h » ('j') | chrome/browser/sync/profile_sync_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698