OLD | NEW |
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 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 ASSERT_EQ("true - is controlled", script_result); | 1233 ASSERT_EQ("true - is controlled", script_result); |
1234 | 1234 |
1235 notification_manager()->CancelAll(); | 1235 notification_manager()->CancelAll(); |
1236 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); | 1236 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); |
1237 | 1237 |
1238 // We'll need to specify the web_contents in which to eval script, since we're | 1238 // We'll need to specify the web_contents in which to eval script, since we're |
1239 // going to run script in a background tab. | 1239 // going to run script in a background tab. |
1240 content::WebContents* web_contents = | 1240 content::WebContents* web_contents = |
1241 GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 1241 GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
1242 | 1242 |
1243 // Set the site engagement score for the site. Setting it to 4 means it should | 1243 // Set the site engagement score for the site. Setting it to 10 means it |
1244 // have enough budget for two non-shown notification, which cost 2 each. | 1244 // should have a budget of 4, enough for two non-shown notification, which |
1245 SetSiteEngagementScore(web_contents->GetURL(), 4.0); | 1245 // cost 2 each. |
| 1246 SetSiteEngagementScore(web_contents->GetURL(), 10.0); |
1246 | 1247 |
1247 // If the site is visible in an active tab, we should not force a notification | 1248 // If the site is visible in an active tab, we should not force a notification |
1248 // to be shown. Try it twice, since we allow one mistake per 10 push events. | 1249 // to be shown. Try it twice, since we allow one mistake per 10 push events. |
1249 gcm::IncomingMessage message; | 1250 gcm::IncomingMessage message; |
1250 message.sender_id = GetTestApplicationServerKey(); | 1251 message.sender_id = GetTestApplicationServerKey(); |
1251 message.decrypted = true; | 1252 message.decrypted = true; |
1252 for (int n = 0; n < 2; n++) { | 1253 for (int n = 0; n < 2; n++) { |
1253 message.raw_data = "testdata"; | 1254 message.raw_data = "testdata"; |
1254 SendMessageAndWaitUntilHandled(app_identifier, message); | 1255 SendMessageAndWaitUntilHandled(app_identifier, message); |
1255 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 1256 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 2190 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
2190 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2191 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2191 | 2192 |
2192 // After dropping the last subscription background mode is still inactive. | 2193 // After dropping the last subscription background mode is still inactive. |
2193 std::string script_result; | 2194 std::string script_result; |
2194 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2195 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
2195 EXPECT_EQ("unsubscribe result: true", script_result); | 2196 EXPECT_EQ("unsubscribe result: true", script_result); |
2196 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2197 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2197 } | 2198 } |
2198 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2199 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |