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

Side by Side Diff: sync/internal_api/sync_backup_manager_unittest.cc

Issue 437683002: Wire sync shutdown reason from PSS all the way down to sync manager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 "sync/internal_api/sync_backup_manager.h" 5 #include "sync/internal_api/sync_backup_manager.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "sync/internal_api/public/read_node.h" 9 #include "sync/internal_api/public/read_node.h"
10 #include "sync/internal_api/public/read_transaction.h" 10 #include "sync/internal_api/public/read_transaction.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 base::Bind(&OnConfigDone, true), 90 base::Bind(&OnConfigDone, true),
91 base::Bind(&OnConfigDone, false)); 91 base::Bind(&OnConfigDone, false));
92 } 92 }
93 93
94 void HandleInit(bool success) { 94 void HandleInit(bool success) {
95 if (success) { 95 if (success) {
96 loop_.PostTask(FROM_HERE, 96 loop_.PostTask(FROM_HERE,
97 base::Bind(&SyncBackupManagerTest::ConfigureSyncer, 97 base::Bind(&SyncBackupManagerTest::ConfigureSyncer,
98 base::Unretained(this))); 98 base::Unretained(this)));
99 } else { 99 } else {
100 manager_->ShutdownOnSyncThread(); 100 manager_->ShutdownOnSyncThread(STOP_SYNC);
101 } 101 }
102 } 102 }
103 103
104 base::ScopedTempDir temp_dir_; 104 base::ScopedTempDir temp_dir_;
105 base::MessageLoop loop_; // Needed for WeakHandle 105 base::MessageLoop loop_; // Needed for WeakHandle
106 SyncManager* manager_; 106 SyncManager* manager_;
107 }; 107 };
108 108
109 TEST_F(SyncBackupManagerTest, NormalizeAndPersist) { 109 TEST_F(SyncBackupManagerTest, NormalizeAndPersist) {
110 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); 110 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager);
(...skipping 15 matching lines...) Expand all
126 126
127 { 127 {
128 // New entry has server ID and unsynced bit is cleared after saving. 128 // New entry has server ID and unsynced bit is cleared after saving.
129 ReadTransaction trans(FROM_HERE, manager->GetUserShare()); 129 ReadTransaction trans(FROM_HERE, manager->GetUserShare());
130 ReadNode pref(&trans); 130 ReadNode pref(&trans);
131 EXPECT_EQ(BaseNode::INIT_OK, 131 EXPECT_EQ(BaseNode::INIT_OK,
132 pref.InitByClientTagLookup(SEARCH_ENGINES, "test")); 132 pref.InitByClientTagLookup(SEARCH_ENGINES, "test"));
133 EXPECT_TRUE(pref.GetEntry()->GetId().ServerKnows()); 133 EXPECT_TRUE(pref.GetEntry()->GetId().ServerKnows());
134 EXPECT_FALSE(pref.GetEntry()->GetIsUnsynced()); 134 EXPECT_FALSE(pref.GetEntry()->GetIsUnsynced());
135 } 135 }
136 manager->ShutdownOnSyncThread(); 136 manager->ShutdownOnSyncThread(STOP_SYNC);
137 137
138 // Reopen db to verify entry is persisted. 138 // Reopen db to verify entry is persisted.
139 manager.reset(new SyncBackupManager); 139 manager.reset(new SyncBackupManager);
140 InitManager(manager.get(), STORAGE_ON_DISK); 140 InitManager(manager.get(), STORAGE_ON_DISK);
141 { 141 {
142 ReadTransaction trans(FROM_HERE, manager->GetUserShare()); 142 ReadTransaction trans(FROM_HERE, manager->GetUserShare());
143 ReadNode pref(&trans); 143 ReadNode pref(&trans);
144 EXPECT_EQ(BaseNode::INIT_OK, 144 EXPECT_EQ(BaseNode::INIT_OK,
145 pref.InitByClientTagLookup(SEARCH_ENGINES, "test")); 145 pref.InitByClientTagLookup(SEARCH_ENGINES, "test"));
146 EXPECT_TRUE(pref.GetEntry()->GetId().ServerKnows()); 146 EXPECT_TRUE(pref.GetEntry()->GetId().ServerKnows());
147 EXPECT_FALSE(pref.GetEntry()->GetIsUnsynced()); 147 EXPECT_FALSE(pref.GetEntry()->GetIsUnsynced());
148 } 148 }
149 } 149 }
150 150
151 TEST_F(SyncBackupManagerTest, FailToInitialize) { 151 TEST_F(SyncBackupManagerTest, FailToInitialize) {
152 // Test graceful shutdown on initialization failure. 152 // Test graceful shutdown on initialization failure.
153 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager); 153 scoped_ptr<SyncBackupManager> manager(new SyncBackupManager);
154 InitManager(manager.get(), STORAGE_INVALID); 154 InitManager(manager.get(), STORAGE_INVALID);
155 } 155 }
156 156
157 } // anonymous namespace 157 } // anonymous namespace
158 158
159 } // namespace syncer 159 } // namespace syncer
160 160
OLDNEW
« no previous file with comments | « sync/internal_api/public/test/fake_sync_manager.h ('k') | sync/internal_api/sync_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698