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

Unified Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 996813002: Deflake PushMessagingBrowserTest.DenyPushPermissionUnregisters & friends (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix app id lifetime, and simplify usage Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/push_messaging/push_messaging_browsertest.cc
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc
index 7ab3987d556d7a96e05afef681ed81488e4d0f44..02df2377725b9698653be5a5d6b121a17750f21e 100644
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/notifications/notification_test_util.h"
@@ -240,6 +241,8 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
PushMessagingApplicationId GetServiceWorkerAppId(
int64 service_worker_registration_id);
+ void WaitForGetUserDataRoundTrip();
+
net::SpawnedTestServer* https_server() const { return https_server_.get(); }
gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; }
@@ -315,6 +318,22 @@ PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId(
return application_id;
}
+static void WaitForGetUserDataRoundTripCallback(
+ const base::Closure& quit_closure,
+ const std::string& data, bool success, bool not_found) {
+ quit_closure.Run();
+}
+
+void PushMessagingBrowserTest::WaitForGetUserDataRoundTrip() {
+ base::RunLoop run_loop;
+ push_service()->GetSenderId(
+ browser()->profile(),
+ https_server()->GetURL(std::string()).GetOrigin(),
+ 0LL /* service_worker_registration_id */, // Any SW will do.
Bernhard Bauer 2015/03/10 18:03:19 Yeah, I was wondering about that :)
+ base::Bind(&WaitForGetUserDataRoundTripCallback, run_loop.QuitClosure()));
+ run_loop.Run();
+}
+
IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
RegisterSuccessNotificationsGranted) {
if (!IsPushSupported())
@@ -786,6 +805,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
browser()->profile()->GetHostContentSettingsMap()->
ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - default", script_result);
@@ -813,6 +835,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
std::string(),
CONTENT_SETTING_DEFAULT);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - default", script_result);
@@ -840,6 +865,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
std::string(),
CONTENT_SETTING_BLOCK);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - denied", script_result);
@@ -862,6 +890,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
browser()->profile()->GetHostContentSettingsMap()->
ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - default", script_result);
@@ -889,6 +920,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
std::string(),
CONTENT_SETTING_DEFAULT);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - default", script_result);
@@ -916,6 +950,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
std::string(),
CONTENT_SETTING_BLOCK);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - denied", script_result);
@@ -949,6 +986,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
std::string(),
CONTENT_SETTING_ALLOW);
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - granted", script_result);
@@ -1003,6 +1043,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
// The Push service should not unsubcribe |origin| because at no point it was
// left without permission to use Push.
+ WaitForGetUserDataRoundTrip();
+ WaitForGetUserDataRoundTrip();
+
ASSERT_TRUE(RunScript("hasPermission()", &script_result));
EXPECT_EQ("permission status - granted", script_result);
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698