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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 2781413002: [Push API] Fix flaky PushEventNotificationWithoutEventWaitUntil (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 GetAppIdentifierForServiceWorkerRegistration(0LL); 1459 GetAppIdentifierForServiceWorkerRegistration(0LL);
1460 1460
1461 ASSERT_TRUE(RunScript("isControlled()", &script_result)); 1461 ASSERT_TRUE(RunScript("isControlled()", &script_result));
1462 ASSERT_EQ("false - is not controlled", script_result); 1462 ASSERT_EQ("false - is not controlled", script_result);
1463 1463
1464 LoadTestPage(); // Reload to become controlled. 1464 LoadTestPage(); // Reload to become controlled.
1465 1465
1466 ASSERT_TRUE(RunScript("isControlled()", &script_result)); 1466 ASSERT_TRUE(RunScript("isControlled()", &script_result));
1467 ASSERT_EQ("true - is controlled", script_result); 1467 ASSERT_EQ("true - is controlled", script_result);
1468 1468
1469 scoped_refptr<content::MessageLoopRunner> message_loop_runner = 1469 base::RunLoop run_loop;
1470 new content::MessageLoopRunner; 1470 base::Closure quit_barrier =
1471 notification_manager()->SetNotificationAddedCallback( 1471 base::BarrierClosure(2 /* num_closures */, run_loop.QuitClosure());
1472 message_loop_runner->QuitClosure()); 1472 push_service()->SetMessageCallbackForTesting(quit_barrier);
1473 notification_manager()->SetNotificationAddedCallback(quit_barrier);
1473 1474
1474 gcm::IncomingMessage message; 1475 gcm::IncomingMessage message;
1475 message.sender_id = GetTestApplicationServerKey(); 1476 message.sender_id = GetTestApplicationServerKey();
1476 message.raw_data = "shownotification-without-waituntil"; 1477 message.raw_data = "shownotification-without-waituntil";
1477 message.decrypted = true; 1478 message.decrypted = true;
1478 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); 1479 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false));
1479 push_service()->OnMessage(app_identifier.app_id(), message); 1480 push_service()->OnMessage(app_identifier.app_id(), message);
1480 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true)); 1481 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(true));
1481 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); 1482 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents));
1482 EXPECT_EQ("immediate:shownotification-without-waituntil", script_result); 1483 EXPECT_EQ("immediate:shownotification-without-waituntil", script_result);
1483 1484
1484 message_loop_runner->Run(); 1485 run_loop.Run();
1485 1486
1486 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false)); 1487 EXPECT_TRUE(IsRegisteredKeepAliveEqualTo(false));
1487 ASSERT_EQ(1u, notification_manager()->GetNotificationCount()); 1488 ASSERT_EQ(1u, notification_manager()->GetNotificationCount());
1488 EXPECT_EQ("push_test_tag", 1489 EXPECT_EQ("push_test_tag",
1489 notification_manager()->GetNotificationAt(0).tag()); 1490 notification_manager()->GetNotificationAt(0).tag());
1490 1491
1491 // Verify that the renderer process hasn't crashed. 1492 // Verify that the renderer process hasn't crashed.
1492 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 1493 ASSERT_TRUE(RunScript("permissionState()", &script_result));
1493 EXPECT_EQ("permission status - granted", script_result); 1494 EXPECT_EQ("permission status - granted", script_result);
1494 } 1495 }
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure()); 2248 push_service()->SetUnsubscribeCallbackForTesting(run_loop.QuitClosure());
2248 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 2249 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
2249 EXPECT_EQ("unsubscribe result: true", script_result); 2250 EXPECT_EQ("unsubscribe result: true", script_result);
2250 // Background mode is only guaranteed to have updated once the unsubscribe 2251 // Background mode is only guaranteed to have updated once the unsubscribe
2251 // callback for testing has been run (PushSubscription.unsubscribe() usually 2252 // callback for testing has been run (PushSubscription.unsubscribe() usually
2252 // resolves before that, in order to avoid blocking on network retries etc). 2253 // resolves before that, in order to avoid blocking on network retries etc).
2253 run_loop.Run(); 2254 run_loop.Run();
2254 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 2255 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
2255 } 2256 }
2256 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 2257 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698