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

Side by Side Diff: chrome/browser/search_engines/template_url_service_sync_unittest.cc

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fred's review Created 8 years, 9 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/search_engines/template_url.h" 9 #include "chrome/browser/search_engines/template_url.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" 12 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h"
13 #include "chrome/browser/sync/protocol/sync.pb.h"
13 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/testing_pref_service.h" 16 #include "chrome/test/base/testing_pref_service.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using base::Time; 21 using base::Time;
21 22
22 namespace { 23 namespace {
23 24
24 // Extract the GUID from a search engine SyncData. 25 // Extract the GUID from a search engine SyncData.
25 std::string GetGUID(const SyncData& sync_data) { 26 std::string GetGUID(const SyncData& sync_data) {
26 return sync_data.GetSpecifics().GetExtension( 27 return sync_data.GetSpecifics().search_engine().sync_guid();
27 sync_pb::search_engine).sync_guid();
28 } 28 }
29 29
30 // Extract the URL from a search engine SyncData. 30 // Extract the URL from a search engine SyncData.
31 std::string GetURL(const SyncData& sync_data) { 31 std::string GetURL(const SyncData& sync_data) {
32 return sync_data.GetSpecifics().GetExtension( 32 return sync_data.GetSpecifics().search_engine().url();
33 sync_pb::search_engine).url();
34 } 33 }
35 34
36 // Extract the keyword from a search engine SyncData. 35 // Extract the keyword from a search engine SyncData.
37 std::string GetKeyword(const SyncData& sync_data) { 36 std::string GetKeyword(const SyncData& sync_data) {
38 return sync_data.GetSpecifics().GetExtension( 37 return sync_data.GetSpecifics().search_engine().keyword();
39 sync_pb::search_engine).keyword();
40 } 38 }
41 39
42 // TODO(stevet): Share these with template_url_service_unittest. 40 // TODO(stevet): Share these with template_url_service_unittest.
43 // Set the managed preferences for the default search provider and trigger 41 // Set the managed preferences for the default search provider and trigger
44 // notification. 42 // notification.
45 void SetManagedDefaultSearchPreferences(TemplateURLService* turl_service, 43 void SetManagedDefaultSearchPreferences(TemplateURLService* turl_service,
46 TestingProfile* profile, 44 TestingProfile* profile,
47 bool enabled, 45 bool enabled,
48 const char* name, 46 const char* name,
49 const char* search_url, 47 const char* search_url,
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 model()->MergeDataAndStartSyncing( 1292 model()->MergeDataAndStartSyncing(
1295 syncable::SEARCH_ENGINES, 1293 syncable::SEARCH_ENGINES,
1296 CreateInitialSyncData(), 1294 CreateInitialSyncData(),
1297 processor()); 1295 processor());
1298 1296
1299 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size()); 1297 EXPECT_EQ(3U, model()->GetAllSyncData(syncable::SEARCH_ENGINES).size());
1300 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid")); 1298 EXPECT_FALSE(model()->GetTemplateURLForGUID("whateverguid"));
1301 EXPECT_EQ(model()->GetDefaultSearchProvider(), 1299 EXPECT_EQ(model()->GetDefaultSearchProvider(),
1302 model()->GetTemplateURLForGUID("key1")); 1300 model()->GetTemplateURLForGUID("key1"));
1303 } 1301 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/sync/abstract_profile_sync_service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698