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 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1210 ASSERT_EQ("true - is controlled", script_result); | 1210 ASSERT_EQ("true - is controlled", script_result); |
1211 | 1211 |
1212 notification_manager()->CancelAll(); | 1212 notification_manager()->CancelAll(); |
1213 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); | 1213 ASSERT_EQ(0u, notification_manager()->GetNotificationCount()); |
1214 | 1214 |
1215 // We'll need to specify the web_contents in which to eval script, since we're | 1215 // We'll need to specify the web_contents in which to eval script, since we're |
1216 // going to run script in a background tab. | 1216 // going to run script in a background tab. |
1217 content::WebContents* web_contents = | 1217 content::WebContents* web_contents = |
1218 GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 1218 GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
1219 | 1219 |
1220 // Set the site engagement score for the site. Setting it to 4 means it should | 1220 // Set the site engagement score for the site. Setting it to 10 means it |
1221 // have enough budget for two non-shown notification, which cost 2 each. | 1221 // should have a budget of 4, enough for two non-shown notification, which |
1222 SetSiteEngagementScore(web_contents->GetURL(), 4.0); | 1222 // cost 2 each. |
Peter Beverloo
2017/01/12 14:40:04
I'd love to be able to use constants for this. Can
harkness
2017/01/12 17:44:15
I think that's a great idea, and I will absolutely
| |
1223 SetSiteEngagementScore(web_contents->GetURL(), 10.0); | |
1223 | 1224 |
1224 // If the site is visible in an active tab, we should not force a notification | 1225 // If the site is visible in an active tab, we should not force a notification |
1225 // to be shown. Try it twice, since we allow one mistake per 10 push events. | 1226 // to be shown. Try it twice, since we allow one mistake per 10 push events. |
1226 gcm::IncomingMessage message; | 1227 gcm::IncomingMessage message; |
1227 message.sender_id = GetTestApplicationServerKey(); | 1228 message.sender_id = GetTestApplicationServerKey(); |
1228 message.decrypted = true; | 1229 message.decrypted = true; |
1229 for (int n = 0; n < 2; n++) { | 1230 for (int n = 0; n < 2; n++) { |
1230 message.raw_data = "testdata"; | 1231 message.raw_data = "testdata"; |
1231 SendMessageAndWaitUntilHandled(app_identifier, message); | 1232 SendMessageAndWaitUntilHandled(app_identifier, message); |
1232 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 1233 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2120 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); | 2121 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); |
2121 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2122 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2122 | 2123 |
2123 // After dropping the last subscription background mode is still inactive. | 2124 // After dropping the last subscription background mode is still inactive. |
2124 std::string script_result; | 2125 std::string script_result; |
2125 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 2126 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
2126 EXPECT_EQ("unsubscribe result: true", script_result); | 2127 EXPECT_EQ("unsubscribe result: true", script_result); |
2127 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 2128 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
2128 } | 2129 } |
2129 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 2130 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |