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

Unified Diff: google_apis/gcm/engine/gcm_store_impl_unittest.cc

Issue 884783003: [GCM] Fixing the initialization of last checkin/fetch time if they are (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding unit tests Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/engine/gcm_store_impl_unittest.cc
diff --git a/google_apis/gcm/engine/gcm_store_impl_unittest.cc b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
index e5690fdc39b16fff6161a8b64b58552d175f7506..66177d261edab2f05b0a1edf29918ba1594de914 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -45,7 +45,7 @@ class GCMStoreImplTest : public testing::Test {
GCMStoreImplTest();
~GCMStoreImplTest() override;
- scoped_ptr<GCMStore> BuildGCMStore();
+ scoped_ptr<GCMStoreImpl> BuildGCMStore();
std::string GetNextPersistentId();
@@ -72,8 +72,8 @@ GCMStoreImplTest::GCMStoreImplTest()
GCMStoreImplTest::~GCMStoreImplTest() {}
-scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
- return scoped_ptr<GCMStore>(new GCMStoreImpl(
+scoped_ptr<GCMStoreImpl> GCMStoreImplTest::BuildGCMStore() {
+ return scoped_ptr<GCMStoreImpl>(new GCMStoreImpl(
temp_directory_.path(),
message_loop_.message_loop_proxy(),
make_scoped_ptr<Encryptor>(new FakeEncryptor)));
@@ -137,7 +137,7 @@ TEST_F(GCMStoreImplTest, DeviceCredentials) {
}
TEST_F(GCMStoreImplTest, LastCheckinInfo) {
- scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
+ scoped_ptr<GCMStoreImpl> gcm_store(BuildGCMStore());
scoped_ptr<GCMStore::LoadResult> load_result;
gcm_store->Load(base::Bind(
&GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
@@ -160,6 +160,19 @@ TEST_F(GCMStoreImplTest, LastCheckinInfo) {
PumpLoop();
ASSERT_EQ(last_checkin_time, load_result->last_checkin_time);
ASSERT_EQ(accounts, load_result->last_checkin_accounts);
+
+ // Negative cases, where the value read is gibberish.
+ gcm_store->SetValueForTesting(
+ "last_checkin_time",
+ "gibberish",
+ base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
+ PumpLoop();
+
+ gcm_store = BuildGCMStore().Pass();
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+ PumpLoop();
+ EXPECT_EQ(base::Time(), load_result->last_checkin_time);
}
TEST_F(GCMStoreImplTest, GServicesSettings_ProtocolV2) {
@@ -644,7 +657,7 @@ TEST_F(GCMStoreImplTest, ReloadAfterClose) {
}
TEST_F(GCMStoreImplTest, LastTokenFetchTime) {
- scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
+ scoped_ptr<GCMStoreImpl> gcm_store(BuildGCMStore());
scoped_ptr<GCMStore::LoadResult> load_result;
gcm_store->Load(base::Bind(
&GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
@@ -662,6 +675,19 @@ TEST_F(GCMStoreImplTest, LastTokenFetchTime) {
&GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
PumpLoop();
EXPECT_EQ(last_token_fetch_time, load_result->last_token_fetch_time);
+
+ // Negative cases, where the value read is gibberish.
+ gcm_store->SetValueForTesting(
+ "last_token_fetch_time",
+ "gibberish",
+ base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
+ PumpLoop();
+
+ gcm_store = BuildGCMStore().Pass();
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+ PumpLoop();
+ EXPECT_EQ(base::Time(), load_result->last_token_fetch_time);
}
} // namespace
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698