Index: components/gcm_driver/instance_id/instance_id_driver_unittest.cc |
diff --git a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc |
index 7b4e722e01c9021fa2de916592c4e6e98abc86a9..3843da8d248848e29dc95ee51cf24f3156223c73 100644 |
--- a/components/gcm_driver/instance_id/instance_id_driver_unittest.cc |
+++ b/components/gcm_driver/instance_id/instance_id_driver_unittest.cc |
@@ -248,7 +248,7 @@ void InstanceIDDriverTest::DeleteTokenCompleted(InstanceID::Result result) { |
TEST_F(InstanceIDDriverTest, GetAndRemoveInstanceID) { |
EXPECT_FALSE(driver()->ExistsInstanceID(kTestAppID1)); |
- InstanceID* instance_id = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
EXPECT_TRUE(instance_id); |
EXPECT_TRUE(driver()->ExistsInstanceID(kTestAppID1)); |
@@ -258,7 +258,7 @@ TEST_F(InstanceIDDriverTest, GetAndRemoveInstanceID) { |
TEST_F(InstanceIDDriverTest, NewID) { |
// Creation time should not be set when the ID is not created. |
- InstanceID* instance_id1 = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id1 = driver()->GetInstanceIDForExtensions(kTestAppID1); |
EXPECT_TRUE(GetCreationTime(instance_id1).is_null()); |
// New ID is generated for the first time. |
@@ -272,7 +272,7 @@ TEST_F(InstanceIDDriverTest, NewID) { |
EXPECT_EQ(creation_time, GetCreationTime(instance_id1)); |
// New ID is generated for another app. |
- InstanceID* instance_id2 = driver()->GetInstanceID(kTestAppID2); |
+ InstanceID* instance_id2 = driver()->GetInstanceIDForExtensions(kTestAppID2); |
std::string id2 = GetID(instance_id2); |
EXPECT_TRUE(VerifyInstanceID(id2)); |
EXPECT_NE(id1, id2); |
@@ -280,7 +280,7 @@ TEST_F(InstanceIDDriverTest, NewID) { |
} |
TEST_F(InstanceIDDriverTest, PersistID) { |
- InstanceID* instance_id = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
// Create the ID for the first time. The ID and creation time should be saved |
// to the store. |
@@ -292,7 +292,7 @@ TEST_F(InstanceIDDriverTest, PersistID) { |
// Simulate restart by recreating InstanceIDDriver. Same ID and creation time |
// should be expected. |
RecreateInstanceIDDriver(); |
- instance_id = driver()->GetInstanceID(kTestAppID1); |
+ instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
EXPECT_EQ(creation_time, GetCreationTime(instance_id)); |
EXPECT_EQ(id, GetID(instance_id)); |
@@ -305,12 +305,12 @@ TEST_F(InstanceIDDriverTest, PersistID) { |
// Note that we do not check for different creation time since the test might |
// be run at a very fast server. |
RecreateInstanceIDDriver(); |
- instance_id = driver()->GetInstanceID(kTestAppID1); |
+ instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
EXPECT_NE(id, GetID(instance_id)); |
} |
TEST_F(InstanceIDDriverTest, DeleteID) { |
- InstanceID* instance_id = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
std::string id1 = GetID(instance_id); |
EXPECT_FALSE(id1.empty()); |
EXPECT_FALSE(GetCreationTime(instance_id).is_null()); |
@@ -326,7 +326,7 @@ TEST_F(InstanceIDDriverTest, DeleteID) { |
} |
TEST_F(InstanceIDDriverTest, GetToken) { |
- InstanceID* instance_id = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
std::map<std::string, std::string> options; |
std::string token1 = |
GetToken(instance_id, kAuthorizedEntity1, kScope1, options); |
@@ -350,7 +350,7 @@ TEST_F(InstanceIDDriverTest, GetToken) { |
} |
TEST_F(InstanceIDDriverTest, DeleteToken) { |
- InstanceID* instance_id = driver()->GetInstanceID(kTestAppID1); |
+ InstanceID* instance_id = driver()->GetInstanceIDForExtensions(kTestAppID1); |
std::map<std::string, std::string> options; |
// Gets 2 tokens. |
@@ -376,4 +376,20 @@ TEST_F(InstanceIDDriverTest, DeleteToken) { |
GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); |
} |
+TEST_F(InstanceIDDriverTest, GetWithAndWithoutSubtype) { |
+ ASSERT_FALSE(driver()->ExistsInstanceID(kTestAppID1)); |
+ |
+ InstanceID* iid_without_subtype = |
+ driver()->GetInstanceIDForExtensions(kTestAppID1); |
+ ASSERT_TRUE(iid_without_subtype); |
+ ASSERT_TRUE(driver()->ExistsInstanceID(kTestAppID1)); |
+ |
+ // InstanceIDDriver's caching is currently oblivious to subtypes (ideally this |
+ // would DCHECK instead, since registering the same app_id in both ways is not |
+ // supported). |
+ InstanceID* same_iid = driver()->GetInstanceID(kTestAppID1); |
+ EXPECT_TRUE(same_iid); |
+ EXPECT_EQ(iid_without_subtype, same_iid); |
+} |
+ |
} // namespace instance_id |