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

Side by Side Diff: chrome/browser/sync/profile_sync_service_session_unittest.cc

Issue 10958007: sync: Refactor CreateRoot() test helper function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Found more stuff to clean up Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/public/browser/notification_observer.h" 34 #include "content/public/browser/notification_observer.h"
35 #include "content/public/browser/notification_registrar.h" 35 #include "content/public/browser/notification_registrar.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/test/test_browser_thread.h" 37 #include "content/public/test/test_browser_thread.h"
38 #include "google_apis/gaia/gaia_constants.h" 38 #include "google_apis/gaia/gaia_constants.h"
39 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
40 #include "sync/internal_api/public/base/model_type.h" 40 #include "sync/internal_api/public/base/model_type.h"
41 #include "sync/internal_api/public/change_record.h" 41 #include "sync/internal_api/public/change_record.h"
42 #include "sync/internal_api/public/read_node.h" 42 #include "sync/internal_api/public/read_node.h"
43 #include "sync/internal_api/public/read_transaction.h" 43 #include "sync/internal_api/public/read_transaction.h"
44 #include "sync/internal_api/public/test/test_user_share.h"
44 #include "sync/internal_api/public/write_node.h" 45 #include "sync/internal_api/public/write_node.h"
45 #include "sync/internal_api/public/write_transaction.h" 46 #include "sync/internal_api/public/write_transaction.h"
46 #include "sync/protocol/session_specifics.pb.h" 47 #include "sync/protocol/session_specifics.pb.h"
47 #include "sync/protocol/sync.pb.h" 48 #include "sync/protocol/sync.pb.h"
48 #include "sync/test/engine/test_id_factory.h"
49 #include "testing/gmock/include/gmock/gmock.h" 49 #include "testing/gmock/include/gmock/gmock.h"
50 #include "testing/gtest/include/gtest/gtest.h" 50 #include "testing/gtest/include/gtest/gtest.h"
51 #include "ui/base/ui_base_types.h" 51 #include "ui/base/ui_base_types.h"
52 52
53 using browser_sync::SessionChangeProcessor; 53 using browser_sync::SessionChangeProcessor;
54 using browser_sync::SessionDataTypeController; 54 using browser_sync::SessionDataTypeController;
55 using browser_sync::SessionModelAssociator; 55 using browser_sync::SessionModelAssociator;
56 using browser_sync::SyncBackendHost; 56 using browser_sync::SyncBackendHost;
57 using content::BrowserThread; 57 using content::BrowserThread;
58 using syncer::ChangeRecord; 58 using syncer::ChangeRecord;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 : public BrowserWithTestWindowTest, 153 : public BrowserWithTestWindowTest,
154 public content::NotificationObserver { 154 public content::NotificationObserver {
155 public: 155 public:
156 ProfileSyncServiceSessionTest() 156 ProfileSyncServiceSessionTest()
157 : io_thread_(BrowserThread::IO), 157 : io_thread_(BrowserThread::IO),
158 window_bounds_(0, 1, 2, 3), 158 window_bounds_(0, 1, 2, 3),
159 notified_of_update_(false), 159 notified_of_update_(false),
160 notified_of_refresh_(false) {} 160 notified_of_refresh_(false) {}
161 ProfileSyncService* sync_service() { return sync_service_.get(); } 161 ProfileSyncService* sync_service() { return sync_service_.get(); }
162 162
163 TestIdFactory* ids() { return sync_service_->id_factory(); }
164
165 protected: 163 protected:
166 virtual TestingProfile* CreateProfile() OVERRIDE { 164 virtual TestingProfile* CreateProfile() OVERRIDE {
167 TestingProfile* profile = new TestingProfile(); 165 TestingProfile* profile = new TestingProfile();
168 // Don't want the profile to create a real ProfileSyncService. 166 // Don't want the profile to create a real ProfileSyncService.
169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile, 167 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile,
170 NULL); 168 NULL);
171 return profile; 169 return profile;
172 } 170 }
173 171
174 virtual void SetUp() { 172 virtual void SetUp() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 success_(false) { 278 success_(false) {
281 } 279 }
282 280
283 virtual ~CreateRootHelper() {} 281 virtual ~CreateRootHelper() {}
284 282
285 const base::Closure& callback() const { return callback_; } 283 const base::Closure& callback() const { return callback_; }
286 bool success() { return success_; } 284 bool success() { return success_; }
287 285
288 private: 286 private:
289 void CreateRootCallback(ProfileSyncServiceSessionTest* test) { 287 void CreateRootCallback(ProfileSyncServiceSessionTest* test) {
290 success_ = ProfileSyncServiceTestHelper::CreateRoot( 288 success_ = syncer::TestUserShare::CreateRoot(
291 syncer::SESSIONS, test->sync_service()->GetUserShare(), test->ids()); 289 syncer::SESSIONS, test->sync_service()->GetUserShare());
292 } 290 }
293 291
294 base::Closure callback_; 292 base::Closure callback_;
295 bool success_; 293 bool success_;
296 }; 294 };
297 295
298 // Test that we can write this machine's session to a node and retrieve it. 296 // Test that we can write this machine's session to a node and retrieve it.
299 TEST_F(ProfileSyncServiceSessionTest, WriteSessionToNode) { 297 TEST_F(ProfileSyncServiceSessionTest, WriteSessionToNode) {
300 CreateRootHelper create_root(this); 298 CreateRootHelper create_root(this);
301 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); 299 ASSERT_TRUE(StartSyncService(create_root.callback(), false));
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 sync_pb::SessionSpecifics specifics; 1193 sync_pb::SessionSpecifics specifics;
1196 header.SetSessionSpecifics(specifics); 1194 header.SetSessionSpecifics(specifics);
1197 } 1195 }
1198 // Ensure we associate properly despite the pre-existing node with our local 1196 // Ensure we associate properly despite the pre-existing node with our local
1199 // tag. 1197 // tag.
1200 error = model_associator_->AssociateModels(); 1198 error = model_associator_->AssociateModels();
1201 ASSERT_FALSE(error.IsSet()); 1199 ASSERT_FALSE(error.IsSet());
1202 } 1200 }
1203 1201
1204 } // namespace browser_sync 1202 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698