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

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

Issue 955673004: Move gcm-independent parts of push messaging out of gcm namespace and directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove redundant cast Created 5 years, 9 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 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/services/gcm/push_messaging_application_id.h" 5 #include "chrome/browser/push_messaging/push_messaging_application_id.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace gcm {
9
10 class PushMessagingApplicationIdTest : public testing::Test { 8 class PushMessagingApplicationIdTest : public testing::Test {
11 protected: 9 protected:
12 PushMessagingApplicationId GenerateId( 10 PushMessagingApplicationId GenerateId(
13 const GURL& origin, 11 const GURL& origin,
14 int64 service_worker_registration_id) { 12 int64 service_worker_registration_id) {
15 // To bypass DCHECK in PushMessagingApplicationId::Generate, we just use it 13 // To bypass DCHECK in PushMessagingApplicationId::Generate, we just use it
16 // to generate app_id_guid, and then use private constructor. 14 // to generate app_id_guid, and then use private constructor.
17 std::string app_id_guid = gcm::PushMessagingApplicationId::Generate( 15 std::string app_id_guid = PushMessagingApplicationId::Generate(
18 GURL("https://www.example.com/"), 1).app_id_guid(); 16 GURL("https://www.example.com/"), 1).app_id_guid();
19 return PushMessagingApplicationId(app_id_guid, origin, 17 return PushMessagingApplicationId(app_id_guid, origin,
20 service_worker_registration_id); 18 service_worker_registration_id);
21 } 19 }
22 }; 20 };
23 21
24 TEST_F(PushMessagingApplicationIdTest, ConstructorValidity) { 22 TEST_F(PushMessagingApplicationIdTest, ConstructorValidity) {
25 EXPECT_TRUE(GenerateId(GURL("https://www.example.com/"), 1).IsValid()); 23 EXPECT_TRUE(GenerateId(GURL("https://www.example.com/"), 1).IsValid());
26 EXPECT_TRUE(GenerateId(GURL("https://www.example.com"), 1).IsValid()); 24 EXPECT_TRUE(GenerateId(GURL("https://www.example.com"), 1).IsValid());
27 EXPECT_FALSE(GenerateId(GURL(""), 1).IsValid()); 25 EXPECT_FALSE(GenerateId(GURL(""), 1).IsValid());
28 EXPECT_FALSE(GenerateId(GURL("foo"), 1).IsValid()); 26 EXPECT_FALSE(GenerateId(GURL("foo"), 1).IsValid());
29 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/foo"), 1).IsValid()); 27 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/foo"), 1).IsValid());
30 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/#foo"), 1).IsValid()); 28 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/#foo"), 1).IsValid());
31 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/"), -1).IsValid()); 29 EXPECT_FALSE(GenerateId(GURL("https://www.example.com/"), -1).IsValid());
32 } 30 }
33 31
34 TEST_F(PushMessagingApplicationIdTest, UniqueGuids) { 32 TEST_F(PushMessagingApplicationIdTest, UniqueGuids) {
35 EXPECT_NE(gcm::PushMessagingApplicationId::Generate( 33 EXPECT_NE(PushMessagingApplicationId::Generate(
36 GURL("https://www.example.com/"), 1).app_id_guid(), 34 GURL("https://www.example.com/"), 1).app_id_guid(),
37 gcm::PushMessagingApplicationId::Generate( 35 PushMessagingApplicationId::Generate(
38 GURL("https://www.example.com/"), 1).app_id_guid()); 36 GURL("https://www.example.com/"), 1).app_id_guid());
39 } 37 }
40
41 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698