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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host_unittest.cc

Issue 7524033: Add a scoper object for URLFetcher::Factory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/glue/sync_backend_host.h" 5 #include "chrome/browser/sync/glue/sync_backend_host.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "chrome/browser/sync/engine/model_safe_worker.h" 11 #include "chrome/browser/sync/engine/model_safe_worker.h"
12 #include "chrome/browser/sync/engine/syncapi.h" 12 #include "chrome/browser/sync/engine/syncapi.h"
13 #include "chrome/browser/sync/glue/data_type_controller.h" 13 #include "chrome/browser/sync/glue/data_type_controller.h"
14 #include "chrome/browser/sync/syncable/model_type.h" 14 #include "chrome/browser/sync/syncable/model_type.h"
15 #include "chrome/test/testing_profile.h" 15 #include "chrome/test/testing_profile.h"
16 #include "chrome/test/test_url_request_context_getter.h" 16 #include "chrome/test/test_url_request_context_getter.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "content/common/url_fetcher.h" 18 #include "content/common/url_fetcher.h"
19 #include "content/common/test_url_fetcher_factory.h" 19 #include "content/test/test_url_fetcher_factory.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 // TODO(akalin): Remove this once we fix the TODO below. 24 // TODO(akalin): Remove this once we fix the TODO below.
25 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 27
28 namespace browser_sync { 28 namespace browser_sync {
29 29
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 MessageLoop ui_loop_; 74 MessageLoop ui_loop_;
75 BrowserThread ui_thread_; 75 BrowserThread ui_thread_;
76 BrowserThread io_thread_; 76 BrowserThread io_thread_;
77 }; 77 };
78 78
79 TEST_F(SyncBackendHostTest, InitShutdown) { 79 TEST_F(SyncBackendHostTest, InitShutdown) {
80 std::string k_mock_url = "http://www.example.com"; 80 std::string k_mock_url = "http://www.example.com";
81 FakeURLFetcherFactory test_factory_; 81 FakeURLFetcherFactory test_factory_;
82 test_factory_.SetFakeResponse(k_mock_url + "/time?command=get_time", "", 82 test_factory_.SetFakeResponse(k_mock_url + "/time?command=get_time", "",
83 false); 83 false);
84 URLFetcher::set_factory(&test_factory_);
85 84
86 TestingProfile profile; 85 TestingProfile profile;
87 profile.CreateRequestContext(); 86 profile.CreateRequestContext();
88 87
89 SyncBackendHost backend(&profile); 88 SyncBackendHost backend(&profile);
90 89
91 // TODO(akalin): Handle this in SyncBackendHost instead of in 90 // TODO(akalin): Handle this in SyncBackendHost instead of in
92 // ProfileSyncService, or maybe figure out a way to share the 91 // ProfileSyncService, or maybe figure out a way to share the
93 // "register sync prefs" code. 92 // "register sync prefs" code.
94 PrefService* pref_service = profile.GetPrefs(); 93 PrefService* pref_service = profile.GetPrefs();
95 pref_service->RegisterStringPref(prefs::kEncryptionBootstrapToken, ""); 94 pref_service->RegisterStringPref(prefs::kEncryptionBootstrapToken, "");
96 pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted, 95 pref_service->RegisterBooleanPref(prefs::kSyncHasSetupCompleted,
97 false, 96 false,
98 PrefService::UNSYNCABLE_PREF); 97 PrefService::UNSYNCABLE_PREF);
99 98
100 MockSyncFrontend mock_frontend; 99 MockSyncFrontend mock_frontend;
101 sync_api::SyncCredentials credentials; 100 sync_api::SyncCredentials credentials;
102 credentials.email = "user@example.com"; 101 credentials.email = "user@example.com";
103 credentials.sync_token = "sync_token"; 102 credentials.sync_token = "sync_token";
104 backend.Initialize(&mock_frontend, 103 backend.Initialize(&mock_frontend,
105 GURL(k_mock_url), 104 GURL(k_mock_url),
106 syncable::ModelTypeSet(), 105 syncable::ModelTypeSet(),
107 credentials, 106 credentials,
108 true); 107 true);
109 backend.Shutdown(false); 108 backend.Shutdown(false);
110 URLFetcher::set_factory(NULL);
111 } 109 }
112 110
113 TEST_F(SyncBackendHostTest, MakePendingConfigModeState) { 111 TEST_F(SyncBackendHostTest, MakePendingConfigModeState) {
114 // Empty. 112 // Empty.
115 { 113 {
116 DataTypeController::TypeMap data_type_controllers; 114 DataTypeController::TypeMap data_type_controllers;
117 syncable::ModelTypeSet types; 115 syncable::ModelTypeSet types;
118 ModelSafeRoutingInfo routing_info; 116 ModelSafeRoutingInfo routing_info;
119 117
120 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState> 118 scoped_ptr<SyncBackendHost::PendingConfigureDataTypesState>
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 EXPECT_EQ(types, state->initial_types); 260 EXPECT_EQ(types, state->initial_types);
263 EXPECT_TRUE(state->deleted_type); 261 EXPECT_TRUE(state->deleted_type);
264 262
265 EXPECT_TRUE(state->added_types.none()); 263 EXPECT_TRUE(state->added_types.none());
266 } 264 }
267 } 265 }
268 266
269 // TODO(akalin): Write more SyncBackendHost unit tests. 267 // TODO(akalin): Write more SyncBackendHost unit tests.
270 268
271 } // namespace browser_sync 269 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/http_bridge_unittest.cc ('k') | chrome/browser/sync/signin_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698