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

Side by Side Diff: content/browser/notifications/notification_id_generator_unittest.cc

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: comments Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "content/browser/notifications/notification_id_generator.h" 9 #include "content/browser/notifications/notification_id_generator.h"
10 #include "content/public/test/test_browser_context.h" 10 #include "content/public/test/test_browser_context.h"
(...skipping 19 matching lines...) Expand all
30 bool IsOffTheRecord() const override { return incognito_; } 30 bool IsOffTheRecord() const override { return incognito_; }
31 31
32 private: 32 private:
33 bool incognito_ = false; 33 bool incognito_ = false;
34 34
35 DISALLOW_COPY_AND_ASSIGN(TestBrowserContextConfigurableIncognito); 35 DISALLOW_COPY_AND_ASSIGN(TestBrowserContextConfigurableIncognito);
36 }; 36 };
37 37
38 class NotificationIdGeneratorTest : public ::testing::Test { 38 class NotificationIdGeneratorTest : public ::testing::Test {
39 public: 39 public:
40 NotificationIdGeneratorTest() 40 NotificationIdGeneratorTest() : generator_(&browser_context_) {}
41 : generator_(&browser_context_, kRenderProcessId) {}
42 41
43 void SetUp() override {} 42 void SetUp() override {}
44 43
45 protected: 44 protected:
46 GURL origin() const { return GURL("https://example.com"); } 45 GURL origin() const { return GURL("https://example.com"); }
47 46
48 TestBrowserContextConfigurableIncognito* browser_context() { 47 TestBrowserContextConfigurableIncognito* browser_context() {
49 return &browser_context_; 48 return &browser_context_;
50 } 49 }
51 50
(...skipping 19 matching lines...) Expand all
71 generator()->GenerateForPersistentNotification( 70 generator()->GenerateForPersistentNotification(
72 origin(), kExampleTag, kPersistentNotificationId)); 71 origin(), kExampleTag, kPersistentNotificationId));
73 72
74 EXPECT_EQ(generator()->GenerateForPersistentNotification( 73 EXPECT_EQ(generator()->GenerateForPersistentNotification(
75 origin(), "" /* tag */, kPersistentNotificationId), 74 origin(), "" /* tag */, kPersistentNotificationId),
76 generator()->GenerateForPersistentNotification( 75 generator()->GenerateForPersistentNotification(
77 origin(), "" /* tag */, kPersistentNotificationId)); 76 origin(), "" /* tag */, kPersistentNotificationId));
78 77
79 // Non-persistent notifications. 78 // Non-persistent notifications.
80 EXPECT_EQ(generator()->GenerateForNonPersistentNotification( 79 EXPECT_EQ(generator()->GenerateForNonPersistentNotification(
81 origin(), kExampleTag, kNonPersistentNotificationId), 80 origin(), kExampleTag, kNonPersistentNotificationId,
81 kRenderProcessId),
82 generator()->GenerateForNonPersistentNotification( 82 generator()->GenerateForNonPersistentNotification(
83 origin(), kExampleTag, kNonPersistentNotificationId)); 83 origin(), kExampleTag, kNonPersistentNotificationId,
84 kRenderProcessId));
84 85
85 EXPECT_EQ(generator()->GenerateForNonPersistentNotification( 86 EXPECT_EQ(generator()->GenerateForNonPersistentNotification(
86 origin(), "" /* tag */, kNonPersistentNotificationId), 87 origin(), "" /* tag */, kNonPersistentNotificationId,
88 kRenderProcessId),
87 generator()->GenerateForNonPersistentNotification( 89 generator()->GenerateForNonPersistentNotification(
88 origin(), "" /* tag */, kNonPersistentNotificationId)); 90 origin(), "" /* tag */, kNonPersistentNotificationId,
91 kRenderProcessId));
89 } 92 }
90 93
91 // Uniqueness of notification ids will be impacted by the browser context. 94 // Uniqueness of notification ids will be impacted by the browser context.
92 TEST_F(NotificationIdGeneratorTest, DifferentBrowserContexts) { 95 TEST_F(NotificationIdGeneratorTest, DifferentBrowserContexts) {
93 TestBrowserContextConfigurableIncognito second_browser_context; 96 TestBrowserContextConfigurableIncognito second_browser_context;
94 NotificationIdGenerator second_generator(&second_browser_context, 97 NotificationIdGenerator second_generator(&second_browser_context);
95 kRenderProcessId);
96 98
97 // Persistent notifications. 99 // Persistent notifications.
98 EXPECT_NE(generator()->GenerateForPersistentNotification( 100 EXPECT_NE(generator()->GenerateForPersistentNotification(
99 origin(), kExampleTag, kPersistentNotificationId), 101 origin(), kExampleTag, kPersistentNotificationId),
100 second_generator.GenerateForPersistentNotification( 102 second_generator.GenerateForPersistentNotification(
101 origin(), kExampleTag, kPersistentNotificationId)); 103 origin(), kExampleTag, kPersistentNotificationId));
102 104
103 EXPECT_NE(generator()->GenerateForPersistentNotification( 105 EXPECT_NE(generator()->GenerateForPersistentNotification(
104 origin(), "" /* tag */, kPersistentNotificationId), 106 origin(), "" /* tag */, kPersistentNotificationId),
105 second_generator.GenerateForPersistentNotification( 107 second_generator.GenerateForPersistentNotification(
106 origin(), "" /* tag */, kPersistentNotificationId)); 108 origin(), "" /* tag */, kPersistentNotificationId));
107 109
108 // Non-persistent notifications. 110 // Non-persistent notifications.
109 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 111 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
110 origin(), kExampleTag, kNonPersistentNotificationId), 112 origin(), kExampleTag, kNonPersistentNotificationId,
113 kRenderProcessId),
111 second_generator.GenerateForNonPersistentNotification( 114 second_generator.GenerateForNonPersistentNotification(
112 origin(), kExampleTag, kNonPersistentNotificationId)); 115 origin(), kExampleTag, kNonPersistentNotificationId,
116 kRenderProcessId));
113 117
114 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 118 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
115 origin(), "" /* tag */, kNonPersistentNotificationId), 119 origin(), "" /* tag */, kNonPersistentNotificationId,
120 kRenderProcessId),
116 second_generator.GenerateForNonPersistentNotification( 121 second_generator.GenerateForNonPersistentNotification(
117 origin(), "" /* tag */, kNonPersistentNotificationId)); 122 origin(), "" /* tag */, kNonPersistentNotificationId,
123 kRenderProcessId));
118 } 124 }
119 125
120 // Uniqueness of notification ids will be impacted by the fact whether the 126 // Uniqueness of notification ids will be impacted by the fact whether the
121 // browser context is in Incognito mode. 127 // browser context is in Incognito mode.
122 TEST_F(NotificationIdGeneratorTest, DifferentIncognitoStates) { 128 TEST_F(NotificationIdGeneratorTest, DifferentIncognitoStates) {
123 ASSERT_FALSE(browser_context()->IsOffTheRecord()); 129 ASSERT_FALSE(browser_context()->IsOffTheRecord());
124 130
125 // Persistent notifications. 131 // Persistent notifications.
126 std::string normal_persistent_notification_id = 132 std::string normal_persistent_notification_id =
127 generator()->GenerateForPersistentNotification(origin(), kExampleTag, 133 generator()->GenerateForPersistentNotification(origin(), kExampleTag,
128 kPersistentNotificationId); 134 kPersistentNotificationId);
129 135
130 browser_context()->set_incognito(true); 136 browser_context()->set_incognito(true);
131 ASSERT_TRUE(browser_context()->IsOffTheRecord()); 137 ASSERT_TRUE(browser_context()->IsOffTheRecord());
132 138
133 std::string incognito_persistent_notification_id = 139 std::string incognito_persistent_notification_id =
134 generator()->GenerateForPersistentNotification(origin(), kExampleTag, 140 generator()->GenerateForPersistentNotification(origin(), kExampleTag,
135 kPersistentNotificationId); 141 kPersistentNotificationId);
136 142
137 EXPECT_NE(normal_persistent_notification_id, 143 EXPECT_NE(normal_persistent_notification_id,
138 incognito_persistent_notification_id); 144 incognito_persistent_notification_id);
139 145
140 browser_context()->set_incognito(false); 146 browser_context()->set_incognito(false);
141 147
142 // Non-persistent notifications. 148 // Non-persistent notifications.
143 ASSERT_FALSE(browser_context()->IsOffTheRecord()); 149 ASSERT_FALSE(browser_context()->IsOffTheRecord());
144 150
145 std::string normal_non_persistent_notification_id = 151 std::string normal_non_persistent_notification_id =
146 generator()->GenerateForNonPersistentNotification( 152 generator()->GenerateForNonPersistentNotification(
147 origin(), kExampleTag, kNonPersistentNotificationId); 153 origin(), kExampleTag, kNonPersistentNotificationId,
154 kRenderProcessId);
148 155
149 browser_context()->set_incognito(true); 156 browser_context()->set_incognito(true);
150 ASSERT_TRUE(browser_context()->IsOffTheRecord()); 157 ASSERT_TRUE(browser_context()->IsOffTheRecord());
151 158
152 std::string incognito_non_persistent_notification_id = 159 std::string incognito_non_persistent_notification_id =
153 generator()->GenerateForNonPersistentNotification( 160 generator()->GenerateForNonPersistentNotification(
154 origin(), kExampleTag, kNonPersistentNotificationId); 161 origin(), kExampleTag, kNonPersistentNotificationId,
162 kRenderProcessId);
155 163
156 EXPECT_NE(normal_non_persistent_notification_id, 164 EXPECT_NE(normal_non_persistent_notification_id,
157 incognito_non_persistent_notification_id); 165 incognito_non_persistent_notification_id);
158 } 166 }
159 167
160 // The origin of the notification will impact the generated notification id. 168 // The origin of the notification will impact the generated notification id.
161 TEST_F(NotificationIdGeneratorTest, DifferentOrigins) { 169 TEST_F(NotificationIdGeneratorTest, DifferentOrigins) {
162 GURL different_origin("https://example2.com"); 170 GURL different_origin("https://example2.com");
163 171
164 // Persistent notifications. 172 // Persistent notifications.
165 EXPECT_NE(generator()->GenerateForPersistentNotification( 173 EXPECT_NE(generator()->GenerateForPersistentNotification(
166 origin(), kExampleTag, kPersistentNotificationId), 174 origin(), kExampleTag, kPersistentNotificationId),
167 generator()->GenerateForPersistentNotification( 175 generator()->GenerateForPersistentNotification(
168 different_origin, kExampleTag, kPersistentNotificationId)); 176 different_origin, kExampleTag, kPersistentNotificationId));
169 177
170 // Non-persistent notifications. 178 // Non-persistent notifications.
171 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 179 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
172 origin(), kExampleTag, kNonPersistentNotificationId), 180 origin(), kExampleTag, kNonPersistentNotificationId,
181 kRenderProcessId),
173 generator()->GenerateForNonPersistentNotification( 182 generator()->GenerateForNonPersistentNotification(
174 different_origin, kExampleTag, kNonPersistentNotificationId)); 183 different_origin, kExampleTag, kNonPersistentNotificationId,
184 kRenderProcessId));
175 } 185 }
176 186
177 // The tag, when non-empty, will impact the generated notification id. 187 // The tag, when non-empty, will impact the generated notification id.
178 TEST_F(NotificationIdGeneratorTest, DifferentTags) { 188 TEST_F(NotificationIdGeneratorTest, DifferentTags) {
179 const std::string& different_tag = std::string(kExampleTag) + "2"; 189 const std::string& different_tag = std::string(kExampleTag) + "2";
180 190
181 // Persistent notifications. 191 // Persistent notifications.
182 EXPECT_NE(generator()->GenerateForPersistentNotification( 192 EXPECT_NE(generator()->GenerateForPersistentNotification(
183 origin(), kExampleTag, kPersistentNotificationId), 193 origin(), kExampleTag, kPersistentNotificationId),
184 generator()->GenerateForPersistentNotification( 194 generator()->GenerateForPersistentNotification(
185 origin(), different_tag, kPersistentNotificationId)); 195 origin(), different_tag, kPersistentNotificationId));
186 196
187 // Non-persistent notifications. 197 // Non-persistent notifications.
188 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 198 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
189 origin(), kExampleTag, kNonPersistentNotificationId), 199 origin(), kExampleTag, kNonPersistentNotificationId,
200 kRenderProcessId),
190 generator()->GenerateForNonPersistentNotification( 201 generator()->GenerateForNonPersistentNotification(
191 origin(), different_tag, kNonPersistentNotificationId)); 202 origin(), different_tag, kNonPersistentNotificationId,
203 kRenderProcessId));
192 } 204 }
193 205
194 // The persistent or non-persistent notification id will impact the generated 206 // The persistent or non-persistent notification id will impact the generated
195 // notification id when the tag is empty. 207 // notification id when the tag is empty.
196 TEST_F(NotificationIdGeneratorTest, DifferentIds) { 208 TEST_F(NotificationIdGeneratorTest, DifferentIds) {
197 NotificationIdGenerator second_generator(browser_context(),
198 kRenderProcessId + 1);
199
200 // Persistent notifications. 209 // Persistent notifications.
201 EXPECT_NE(generator()->GenerateForPersistentNotification( 210 EXPECT_NE(generator()->GenerateForPersistentNotification(
202 origin(), "" /* tag */, kPersistentNotificationId), 211 origin(), "" /* tag */, kPersistentNotificationId),
203 generator()->GenerateForPersistentNotification( 212 generator()->GenerateForPersistentNotification(
204 origin(), "" /* tag */, kPersistentNotificationId + 1)); 213 origin(), "" /* tag */, kPersistentNotificationId + 1));
205 214
206 // Non-persistent notifications. 215 // Non-persistent notifications.
207 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 216 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
208 origin(), "" /* tag */, kNonPersistentNotificationId), 217 origin(), "" /* tag */, kNonPersistentNotificationId,
218 kRenderProcessId),
209 generator()->GenerateForNonPersistentNotification( 219 generator()->GenerateForNonPersistentNotification(
210 origin(), "" /* tag */, kNonPersistentNotificationId + 1)); 220 origin(), "" /* tag */, kNonPersistentNotificationId + 1,
221 kRenderProcessId));
211 222
212 // Non-persistent when a tag is being used. 223 // Non-persistent when a tag is being used.
213 EXPECT_EQ(generator()->GenerateForNonPersistentNotification( 224 EXPECT_EQ(generator()->GenerateForNonPersistentNotification(
214 origin(), kExampleTag, kNonPersistentNotificationId), 225 origin(), kExampleTag, kNonPersistentNotificationId,
215 second_generator.GenerateForNonPersistentNotification( 226 kRenderProcessId),
216 origin(), kExampleTag, kNonPersistentNotificationId)); 227 generator()->GenerateForNonPersistentNotification(
228 origin(), kExampleTag, kNonPersistentNotificationId,
229 kRenderProcessId + 1));
217 } 230 }
218 231
219 // Using a numeric tag that could resemble a persistent notification id should 232 // Using a numeric tag that could resemble a persistent notification id should
220 // not be equal to a notification without a tag, but with that id. 233 // not be equal to a notification without a tag, but with that id.
221 TEST_F(NotificationIdGeneratorTest, NumericTagAmbiguity) { 234 TEST_F(NotificationIdGeneratorTest, NumericTagAmbiguity) {
222 // Persistent notifications. 235 // Persistent notifications.
223 EXPECT_NE(generator()->GenerateForPersistentNotification( 236 EXPECT_NE(generator()->GenerateForPersistentNotification(
224 origin(), base::Int64ToString(kPersistentNotificationId), 237 origin(), base::Int64ToString(kPersistentNotificationId),
225 kPersistentNotificationId), 238 kPersistentNotificationId),
226 generator()->GenerateForPersistentNotification( 239 generator()->GenerateForPersistentNotification(
227 origin(), "" /* tag */, kPersistentNotificationId)); 240 origin(), "" /* tag */, kPersistentNotificationId));
228 241
229 // Non-persistent notifications. 242 // Non-persistent notifications.
230 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 243 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
231 origin(), base::IntToString(kNonPersistentNotificationId), 244 origin(), base::IntToString(kNonPersistentNotificationId),
232 kNonPersistentNotificationId), 245 kNonPersistentNotificationId, kRenderProcessId),
233 generator()->GenerateForNonPersistentNotification( 246 generator()->GenerateForNonPersistentNotification(
234 origin(), "" /* tag */, kNonPersistentNotificationId)); 247 origin(), "" /* tag */, kNonPersistentNotificationId,
248 kRenderProcessId));
235 } 249 }
236 250
237 // Using port numbers and a tag which, when concatenated, could end up being 251 // Using port numbers and a tag which, when concatenated, could end up being
238 // equal to each other if origins stop ending with slashes. 252 // equal to each other if origins stop ending with slashes.
239 TEST_F(NotificationIdGeneratorTest, OriginPortAmbiguity) { 253 TEST_F(NotificationIdGeneratorTest, OriginPortAmbiguity) {
240 GURL origin_805("https://example.com:805"); 254 GURL origin_805("https://example.com:805");
241 GURL origin_8051("https://example.com:8051"); 255 GURL origin_8051("https://example.com:8051");
242 256
243 // Persistent notifications. 257 // Persistent notifications.
244 EXPECT_NE(generator()->GenerateForPersistentNotification( 258 EXPECT_NE(generator()->GenerateForPersistentNotification(
245 origin_805, "17", kPersistentNotificationId), 259 origin_805, "17", kPersistentNotificationId),
246 generator()->GenerateForPersistentNotification( 260 generator()->GenerateForPersistentNotification(
247 origin_8051, "7", kPersistentNotificationId)); 261 origin_8051, "7", kPersistentNotificationId));
248 262
249 // Non-persistent notifications. 263 // Non-persistent notifications.
250 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 264 EXPECT_NE(
251 origin_805, "17", kNonPersistentNotificationId), 265 generator()->GenerateForNonPersistentNotification(
252 generator()->GenerateForNonPersistentNotification( 266 origin_805, "17", kNonPersistentNotificationId, kRenderProcessId),
253 origin_8051, "7", kNonPersistentNotificationId)); 267 generator()->GenerateForNonPersistentNotification(
268 origin_8051, "7", kNonPersistentNotificationId, kRenderProcessId));
254 } 269 }
255 270
256 // Verifies that the static Is(Non)PersistentNotification helpers can correctly 271 // Verifies that the static Is(Non)PersistentNotification helpers can correctly
257 // identify persistent and non-persistent notification IDs. 272 // identify persistent and non-persistent notification IDs.
258 TEST_F(NotificationIdGeneratorTest, DetectIdFormat) { 273 TEST_F(NotificationIdGeneratorTest, DetectIdFormat) {
259 std::string persistent_id = generator()->GenerateForPersistentNotification( 274 std::string persistent_id = generator()->GenerateForPersistentNotification(
260 origin(), "" /* tag */, kPersistentNotificationId); 275 origin(), "" /* tag */, kPersistentNotificationId);
261 276
262 std::string non_persistent_id = 277 std::string non_persistent_id =
263 generator()->GenerateForNonPersistentNotification( 278 generator()->GenerateForNonPersistentNotification(
264 origin(), "" /* tag */, kNonPersistentNotificationId); 279 origin(), "" /* tag */, kNonPersistentNotificationId,
280 kRenderProcessId);
265 281
266 EXPECT_TRUE(NotificationIdGenerator::IsPersistentNotification(persistent_id)); 282 EXPECT_TRUE(NotificationIdGenerator::IsPersistentNotification(persistent_id));
267 EXPECT_FALSE( 283 EXPECT_FALSE(
268 NotificationIdGenerator::IsNonPersistentNotification(persistent_id)); 284 NotificationIdGenerator::IsNonPersistentNotification(persistent_id));
269 285
270 EXPECT_TRUE( 286 EXPECT_TRUE(
271 NotificationIdGenerator::IsNonPersistentNotification(non_persistent_id)); 287 NotificationIdGenerator::IsNonPersistentNotification(non_persistent_id));
272 EXPECT_FALSE( 288 EXPECT_FALSE(
273 NotificationIdGenerator::IsPersistentNotification(non_persistent_id)); 289 NotificationIdGenerator::IsPersistentNotification(non_persistent_id));
274 } 290 }
275 291
276 // ----------------------------------------------------------------------------- 292 // -----------------------------------------------------------------------------
277 // Persistent notifications 293 // Persistent notifications
278 // 294 //
279 // Tests covering the logic specific to persistent notifications. This kind of 295 // Tests covering the logic specific to persistent notifications. This kind of
280 // notification does not care about the renderer process that created them. 296 // notification does not care about the renderer process that created them.
281 297
282 TEST_F(NotificationIdGeneratorTest, PersistentDifferentRenderProcessIds) { 298 TEST_F(NotificationIdGeneratorTest, PersistentDifferentRenderProcessIds) {
283 NotificationIdGenerator second_generator(browser_context(), 299 NotificationIdGenerator second_generator(browser_context());
284 kRenderProcessId + 1);
285 300
286 EXPECT_EQ(generator()->GenerateForPersistentNotification( 301 EXPECT_EQ(generator()->GenerateForPersistentNotification(
287 origin(), kExampleTag, kPersistentNotificationId), 302 origin(), kExampleTag, kPersistentNotificationId),
288 second_generator.GenerateForPersistentNotification( 303 second_generator.GenerateForPersistentNotification(
289 origin(), kExampleTag, kPersistentNotificationId)); 304 origin(), kExampleTag, kPersistentNotificationId));
290 305
291 EXPECT_EQ(generator()->GenerateForPersistentNotification( 306 EXPECT_EQ(generator()->GenerateForPersistentNotification(
292 origin(), "" /* tag */, kPersistentNotificationId), 307 origin(), "" /* tag */, kPersistentNotificationId),
293 second_generator.GenerateForPersistentNotification( 308 second_generator.GenerateForPersistentNotification(
294 origin(), "" /* tag */, kPersistentNotificationId)); 309 origin(), "" /* tag */, kPersistentNotificationId));
295 } 310 }
296 311
297 // ----------------------------------------------------------------------------- 312 // -----------------------------------------------------------------------------
298 // Non-persistent notifications 313 // Non-persistent notifications
299 // 314 //
300 // Tests covering the logic specific to non-persistent notifications. This kind 315 // Tests covering the logic specific to non-persistent notifications. This kind
301 // of notification cares about the renderer process they were created by when 316 // of notification cares about the renderer process they were created by when
302 // the notification does not have a tag, since multiple renderers would restart 317 // the notification does not have a tag, since multiple renderers would restart
303 // the count for non-persistent notification ids. 318 // the count for non-persistent notification ids.
304 319
305 TEST_F(NotificationIdGeneratorTest, NonPersistentDifferentRenderProcessIds) { 320 TEST_F(NotificationIdGeneratorTest, NonPersistentDifferentRenderProcessIds) {
306 NotificationIdGenerator second_generator(browser_context(),
307 kRenderProcessId + 1);
308
309 EXPECT_EQ(generator()->GenerateForNonPersistentNotification( 321 EXPECT_EQ(generator()->GenerateForNonPersistentNotification(
310 origin(), kExampleTag, kNonPersistentNotificationId), 322 origin(), kExampleTag, kNonPersistentNotificationId,
311 second_generator.GenerateForNonPersistentNotification( 323 kRenderProcessId),
312 origin(), kExampleTag, kNonPersistentNotificationId)); 324 generator()->GenerateForNonPersistentNotification(
325 origin(), kExampleTag, kNonPersistentNotificationId,
326 kRenderProcessId + 1));
313 327
314 EXPECT_NE(generator()->GenerateForNonPersistentNotification( 328 EXPECT_NE(generator()->GenerateForNonPersistentNotification(
315 origin(), "" /* tag */, kNonPersistentNotificationId), 329 origin(), "" /* tag */, kNonPersistentNotificationId,
316 second_generator.GenerateForNonPersistentNotification( 330 kRenderProcessId),
317 origin(), "" /* tag */, kNonPersistentNotificationId)); 331 generator()->GenerateForNonPersistentNotification(
332 origin(), "" /* tag */, kNonPersistentNotificationId,
333 kRenderProcessId + 1));
318 } 334 }
319 335
320 // Concatenation of the render process id and the non-persistent notification 336 // Concatenation of the render process id and the non-persistent notification
321 // id should not result in the generation of a duplicated notification id. 337 // id should not result in the generation of a duplicated notification id.
322 TEST_F(NotificationIdGeneratorTest, NonPersistentRenderProcessIdAmbiguity) { 338 TEST_F(NotificationIdGeneratorTest, NonPersistentRenderProcessIdAmbiguity) {
323 NotificationIdGenerator generator_rpi_5(browser_context(), 5);
324 NotificationIdGenerator generator_rpi_51(browser_context(), 51);
325
326 EXPECT_NE( 339 EXPECT_NE(
327 generator_rpi_5.GenerateForNonPersistentNotification( 340 generator()->GenerateForNonPersistentNotification(
328 origin(), "" /* tag */, 1337 /* non_persistent_notification_id */), 341 origin(), "" /* tag */, 1337 /* non_persistent_notification_id */,
329 generator_rpi_51.GenerateForNonPersistentNotification( 342 5 /* render_process_id */),
330 origin(), "" /* tag */, 337 /* non_persistent_notification_id */)); 343 generator()->GenerateForNonPersistentNotification(
344 origin(), "" /* tag */, 337 /* non_persistent_notification_id */,
345 51 /* render_process_id */));
331 } 346 }
332 347
333 } // namespace 348 } // namespace
334 } // namespace content 349 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698