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

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

Issue 2802015: Massively simplify the NetworkChangeNotifier infrastructure:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
11 #include "chrome/browser/sync/engine/syncapi.h" 11 #include "chrome/browser/sync/engine/syncapi.h"
12 #include "chrome/browser/sync/glue/data_type_controller.h" 12 #include "chrome/browser/sync/glue/data_type_controller.h"
13 #include "chrome/browser/sync/profile_sync_service.h" 13 #include "chrome/browser/sync/profile_sync_service.h"
14 #include "chrome/browser/sync/profile_sync_factory_impl.h" 14 #include "chrome/browser/sync/profile_sync_factory_impl.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/net/fake_network_change_notifier_thread.h"
17 #include "chrome/test/testing_profile.h" 16 #include "chrome/test/testing_profile.h"
18 17
19 using browser_sync::DataTypeController; 18 using browser_sync::DataTypeController;
20 19
21 class ProfileSyncFactoryImplTest : public testing::Test { 20 class ProfileSyncFactoryImplTest : public testing::Test {
22 protected: 21 protected:
23 ProfileSyncFactoryImplTest() 22 ProfileSyncFactoryImplTest()
24 : ui_thread_(ChromeThread::UI, &message_loop_) {} 23 : ui_thread_(ChromeThread::UI, &message_loop_) {}
25 24
26 virtual void SetUp() { 25 virtual void SetUp() {
27 profile_.reset(new TestingProfile()); 26 profile_.reset(new TestingProfile());
28 FilePath program_path(FILE_PATH_LITERAL("chrome.exe")); 27 FilePath program_path(FILE_PATH_LITERAL("chrome.exe"));
29 command_line_.reset(new CommandLine(program_path)); 28 command_line_.reset(new CommandLine(program_path));
30 profile_sync_service_factory_.reset( 29 profile_sync_service_factory_.reset(
31 new ProfileSyncFactoryImpl(profile_.get(), 30 new ProfileSyncFactoryImpl(profile_.get(), command_line_.get()));
32 &fake_network_change_notifier_thread_,
33 command_line_.get()));
34 } 31 }
35 32
36 MessageLoop message_loop_; 33 MessageLoop message_loop_;
37 ChromeThread ui_thread_; 34 ChromeThread ui_thread_;
38 scoped_ptr<Profile> profile_; 35 scoped_ptr<Profile> profile_;
39 scoped_ptr<CommandLine> command_line_; 36 scoped_ptr<CommandLine> command_line_;
40 chrome_common_net::FakeNetworkChangeNotifierThread
41 fake_network_change_notifier_thread_;
42 scoped_ptr<ProfileSyncFactoryImpl> profile_sync_service_factory_; 37 scoped_ptr<ProfileSyncFactoryImpl> profile_sync_service_factory_;
43 }; 38 };
44 39
45 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDefault) { 40 TEST_F(ProfileSyncFactoryImplTest, CreatePSSDefault) {
46 scoped_ptr<ProfileSyncService> pss; 41 scoped_ptr<ProfileSyncService> pss;
47 pss.reset(profile_sync_service_factory_->CreateProfileSyncService()); 42 pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
48 DataTypeController::StateMap controller_states; 43 DataTypeController::StateMap controller_states;
49 DataTypeController::StateMap* controller_states_ptr = &controller_states; 44 DataTypeController::StateMap* controller_states_ptr = &controller_states;
50 pss->GetDataTypeControllerStates(controller_states_ptr); 45 pss->GetDataTypeControllerStates(controller_states_ptr);
51 EXPECT_EQ(4U, controller_states_ptr->size()); 46 EXPECT_EQ(4U, controller_states_ptr->size());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 pss.reset(profile_sync_service_factory_->CreateProfileSyncService()); 98 pss.reset(profile_sync_service_factory_->CreateProfileSyncService());
104 DataTypeController::StateMap controller_states; 99 DataTypeController::StateMap controller_states;
105 DataTypeController::StateMap* controller_states_ptr = &controller_states; 100 DataTypeController::StateMap* controller_states_ptr = &controller_states;
106 pss->GetDataTypeControllerStates(controller_states_ptr); 101 pss->GetDataTypeControllerStates(controller_states_ptr);
107 EXPECT_EQ(3U, controller_states_ptr->size()); 102 EXPECT_EQ(3U, controller_states_ptr->size());
108 EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS)); 103 EXPECT_EQ(1U, controller_states_ptr->count(syncable::BOOKMARKS));
109 EXPECT_EQ(1U, controller_states_ptr->count(syncable::PREFERENCES)); 104 EXPECT_EQ(1U, controller_states_ptr->count(syncable::PREFERENCES));
110 EXPECT_EQ(1U, controller_states_ptr->count(syncable::AUTOFILL)); 105 EXPECT_EQ(1U, controller_states_ptr->count(syncable::AUTOFILL));
111 EXPECT_EQ(0U, controller_states_ptr->count(syncable::THEMES)); 106 EXPECT_EQ(0U, controller_states_ptr->count(syncable::THEMES));
112 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698