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

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

Issue 1140873005: Push API: Avoid false positive DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 5 years, 7 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 | « chrome/browser/push_messaging/push_messaging_app_identifier.cc ('k') | no next file » | 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 "chrome/browser/push_messaging/push_messaging_app_identifier.h" 5 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h"
6 6
7 #include "chrome/test/base/testing_profile.h" 7 #include "chrome/test/base/testing_profile.h"
8 #include "content/public/test/test_browser_thread_bundle.h" 8 #include "content/public/test/test_browser_thread_bundle.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_TRUE(GenerateId(GURL("https://www.example.com/"), -1).is_null()); 69 EXPECT_TRUE(GenerateId(GURL("https://www.example.com/"), -1).is_null());
70 } 70 }
71 71
72 TEST_F(PushMessagingAppIdentifierTest, UniqueGuids) { 72 TEST_F(PushMessagingAppIdentifierTest, UniqueGuids) {
73 EXPECT_NE(PushMessagingAppIdentifier::Generate( 73 EXPECT_NE(PushMessagingAppIdentifier::Generate(
74 GURL("https://www.example.com/"), 1).app_id(), 74 GURL("https://www.example.com/"), 1).app_id(),
75 PushMessagingAppIdentifier::Generate( 75 PushMessagingAppIdentifier::Generate(
76 GURL("https://www.example.com/"), 1).app_id()); 76 GURL("https://www.example.com/"), 1).app_id());
77 } 77 }
78 78
79 TEST_F(PushMessagingAppIdentifierTest, FindInvalidAppId) {
80 // These calls to FindByAppId should not DCHECK.
81 EXPECT_TRUE(PushMessagingAppIdentifier::FindByAppId(profile(), "").is_null());
82 EXPECT_TRUE(PushMessagingAppIdentifier::FindByAppId(
83 profile(), "amhfneadkjmnlefnpidcijoldiibcdnd").is_null());
84 }
85
79 TEST_F(PushMessagingAppIdentifierTest, PersistAndFind) { 86 TEST_F(PushMessagingAppIdentifierTest, PersistAndFind) {
80 ASSERT_TRUE(PushMessagingAppIdentifier::FindByAppId( 87 ASSERT_TRUE(PushMessagingAppIdentifier::FindByAppId(
81 profile(), original_.app_id()).is_null()); 88 profile(), original_.app_id()).is_null());
82 ASSERT_TRUE(PushMessagingAppIdentifier::FindByServiceWorker( 89 ASSERT_TRUE(PushMessagingAppIdentifier::FindByServiceWorker(
83 profile(), original_.origin(), original_.service_worker_registration_id()) 90 profile(), original_.origin(), original_.service_worker_registration_id())
84 .is_null()); 91 .is_null());
85 92
86 // Test basic PersistToPrefs round trips. 93 // Test basic PersistToPrefs round trips.
87 original_.PersistToPrefs(profile()); 94 original_.PersistToPrefs(profile());
88 { 95 {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ExpectAppIdentifiersEqual(different_origin_, app_identifier); 230 ExpectAppIdentifiersEqual(different_origin_, app_identifier);
224 contained_different_origin = true; 231 contained_different_origin = true;
225 } else { 232 } else {
226 ExpectAppIdentifiersEqual(different_sw_, app_identifier); 233 ExpectAppIdentifiersEqual(different_sw_, app_identifier);
227 contained_different_sw = true; 234 contained_different_sw = true;
228 } 235 }
229 } 236 }
230 EXPECT_TRUE(contained_different_origin); 237 EXPECT_TRUE(contained_different_origin);
231 EXPECT_TRUE(contained_different_sw); 238 EXPECT_TRUE(contained_different_sw);
232 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_app_identifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698