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

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

Issue 2534443002: Use notification display service to collect persistent notifications. (Closed)
Patch Set: revert unit test Created 4 years 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/browser/notification_id_verifier.h"
10 #include "content/public/test/test_browser_context.h" 11 #include "content/public/test/test_browser_context.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h" 13 #include "url/gurl.h"
13 14
14 namespace content { 15 namespace content {
15 namespace { 16 namespace {
16 17
17 const int kRenderProcessId = 42; 18 const int kRenderProcessId = 42;
18 const int64_t kPersistentNotificationId = 430; 19 const int64_t kPersistentNotificationId = 430;
19 const int kNonPersistentNotificationId = 5400; 20 const int kNonPersistentNotificationId = 5400;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // identify persistent and non-persistent notification IDs. 273 // identify persistent and non-persistent notification IDs.
273 TEST_F(NotificationIdGeneratorTest, DetectIdFormat) { 274 TEST_F(NotificationIdGeneratorTest, DetectIdFormat) {
274 std::string persistent_id = generator()->GenerateForPersistentNotification( 275 std::string persistent_id = generator()->GenerateForPersistentNotification(
275 origin(), "" /* tag */, kPersistentNotificationId); 276 origin(), "" /* tag */, kPersistentNotificationId);
276 277
277 std::string non_persistent_id = 278 std::string non_persistent_id =
278 generator()->GenerateForNonPersistentNotification( 279 generator()->GenerateForNonPersistentNotification(
279 origin(), "" /* tag */, kNonPersistentNotificationId, 280 origin(), "" /* tag */, kNonPersistentNotificationId,
280 kRenderProcessId); 281 kRenderProcessId);
281 282
282 EXPECT_TRUE(NotificationIdGenerator::IsPersistentNotification(persistent_id)); 283 EXPECT_TRUE(NotificationIdVerifier::IsPersistentNotification(persistent_id));
283 EXPECT_FALSE( 284 EXPECT_FALSE(
284 NotificationIdGenerator::IsNonPersistentNotification(persistent_id)); 285 NotificationIdVerifier::IsNonPersistentNotification(persistent_id));
285 286
286 EXPECT_TRUE( 287 EXPECT_TRUE(
287 NotificationIdGenerator::IsNonPersistentNotification(non_persistent_id)); 288 NotificationIdVerifier::IsNonPersistentNotification(non_persistent_id));
288 EXPECT_FALSE( 289 EXPECT_FALSE(
289 NotificationIdGenerator::IsPersistentNotification(non_persistent_id)); 290 NotificationIdVerifier::IsPersistentNotification(non_persistent_id));
290 } 291 }
291 292
292 // ----------------------------------------------------------------------------- 293 // -----------------------------------------------------------------------------
293 // Persistent notifications 294 // Persistent notifications
294 // 295 //
295 // Tests covering the logic specific to persistent notifications. This kind of 296 // Tests covering the logic specific to persistent notifications. This kind of
296 // notification does not care about the renderer process that created them. 297 // notification does not care about the renderer process that created them.
297 298
298 TEST_F(NotificationIdGeneratorTest, PersistentDifferentRenderProcessIds) { 299 TEST_F(NotificationIdGeneratorTest, PersistentDifferentRenderProcessIds) {
299 NotificationIdGenerator second_generator(browser_context()); 300 NotificationIdGenerator second_generator(browser_context());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 generator()->GenerateForNonPersistentNotification( 341 generator()->GenerateForNonPersistentNotification(
341 origin(), "" /* tag */, 1337 /* non_persistent_notification_id */, 342 origin(), "" /* tag */, 1337 /* non_persistent_notification_id */,
342 5 /* render_process_id */), 343 5 /* render_process_id */),
343 generator()->GenerateForNonPersistentNotification( 344 generator()->GenerateForNonPersistentNotification(
344 origin(), "" /* tag */, 337 /* non_persistent_notification_id */, 345 origin(), "" /* tag */, 337 /* non_persistent_notification_id */,
345 51 /* render_process_id */)); 346 51 /* render_process_id */));
346 } 347 }
347 348
348 } // namespace 349 } // namespace
349 } // namespace content 350 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698