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

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

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "extensions/common/constants.h" 23 #include "extensions/common/constants.h"
24 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
25 #include "sync/api/sync_error_factory.h" 25 #include "sync/api/sync_error_factory.h"
26 #include "sync/api/sync_error_factory_mock.h" 26 #include "sync/api/sync_error_factory_mock.h"
27 #include "sync/protocol/search_engine_specifics.pb.h" 27 #include "sync/protocol/search_engine_specifics.pb.h"
28 #include "sync/protocol/sync.pb.h" 28 #include "sync/protocol/sync.pb.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using base::ASCIIToUTF16;
31 using base::Time; 32 using base::Time;
32 33
33 namespace { 34 namespace {
34 35
35 // Extract the GUID from a search engine syncer::SyncData. 36 // Extract the GUID from a search engine syncer::SyncData.
36 std::string GetGUID(const syncer::SyncData& sync_data) { 37 std::string GetGUID(const syncer::SyncData& sync_data) {
37 return sync_data.GetSpecifics().search_engine().sync_guid(); 38 return sync_data.GetSpecifics().search_engine().sync_guid();
38 } 39 }
39 40
40 // Extract the URL from a search engine syncer::SyncData. 41 // Extract the URL from a search engine syncer::SyncData.
(...skipping 10 matching lines...) Expand all
51 // caller to override the keyword, URL, or GUID fields with empty strings, in 52 // caller to override the keyword, URL, or GUID fields with empty strings, in
52 // order to create custom data that should be handled specially when synced to a 53 // order to create custom data that should be handled specially when synced to a
53 // client. 54 // client.
54 syncer::SyncData CreateCustomSyncData(const TemplateURL& turl, 55 syncer::SyncData CreateCustomSyncData(const TemplateURL& turl,
55 bool autogenerate_keyword, 56 bool autogenerate_keyword,
56 const std::string& url, 57 const std::string& url,
57 const std::string& sync_guid) { 58 const std::string& sync_guid) {
58 sync_pb::EntitySpecifics specifics; 59 sync_pb::EntitySpecifics specifics;
59 sync_pb::SearchEngineSpecifics* se_specifics = 60 sync_pb::SearchEngineSpecifics* se_specifics =
60 specifics.mutable_search_engine(); 61 specifics.mutable_search_engine();
61 se_specifics->set_short_name(UTF16ToUTF8(turl.short_name())); 62 se_specifics->set_short_name(base::UTF16ToUTF8(turl.short_name()));
62 se_specifics->set_keyword( 63 se_specifics->set_keyword(
63 autogenerate_keyword ? std::string() : UTF16ToUTF8(turl.keyword())); 64 autogenerate_keyword ? std::string() : base::UTF16ToUTF8(turl.keyword()));
64 se_specifics->set_favicon_url(turl.favicon_url().spec()); 65 se_specifics->set_favicon_url(turl.favicon_url().spec());
65 se_specifics->set_url(url); 66 se_specifics->set_url(url);
66 se_specifics->set_safe_for_autoreplace(turl.safe_for_autoreplace()); 67 se_specifics->set_safe_for_autoreplace(turl.safe_for_autoreplace());
67 se_specifics->set_originating_url(turl.originating_url().spec()); 68 se_specifics->set_originating_url(turl.originating_url().spec());
68 se_specifics->set_date_created(turl.date_created().ToInternalValue()); 69 se_specifics->set_date_created(turl.date_created().ToInternalValue());
69 se_specifics->set_input_encodings(JoinString(turl.input_encodings(), ';')); 70 se_specifics->set_input_encodings(JoinString(turl.input_encodings(), ';'));
70 se_specifics->set_show_in_default_list(turl.show_in_default_list()); 71 se_specifics->set_show_in_default_list(turl.show_in_default_list());
71 se_specifics->set_suggestions_url(turl.suggestions_url()); 72 se_specifics->set_suggestions_url(turl.suggestions_url());
72 se_specifics->set_prepopulate_id(turl.prepopulate_id()); 73 se_specifics->set_prepopulate_id(turl.prepopulate_id());
73 se_specifics->set_autogenerate_keyword(autogenerate_keyword); 74 se_specifics->set_autogenerate_keyword(autogenerate_keyword);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 EXPECT_EQ("key1", keyword1->sync_guid()); 1255 EXPECT_EQ("key1", keyword1->sync_guid());
1255 TemplateURL* keyword2 = model()->GetTemplateURLForKeyword(google_keyword); 1256 TemplateURL* keyword2 = model()->GetTemplateURLForKeyword(google_keyword);
1256 ASSERT_FALSE(keyword2 == NULL); 1257 ASSERT_FALSE(keyword2 == NULL);
1257 EXPECT_EQ("key2", keyword2->sync_guid()); 1258 EXPECT_EQ("key2", keyword2->sync_guid());
1258 1259
1259 EXPECT_GE(processor()->change_list_size(), 2U); 1260 EXPECT_GE(processor()->change_list_size(), 2U);
1260 ASSERT_TRUE(processor()->contains_guid("key1")); 1261 ASSERT_TRUE(processor()->contains_guid("key1"));
1261 syncer::SyncChange key1_change = processor()->change_for_guid("key1"); 1262 syncer::SyncChange key1_change = processor()->change_for_guid("key1");
1262 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, key1_change.change_type()); 1263 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, key1_change.change_type());
1263 EXPECT_EQ(keyword1->keyword(), 1264 EXPECT_EQ(keyword1->keyword(),
1264 UTF8ToUTF16(GetKeyword(key1_change.sync_data()))); 1265 base::UTF8ToUTF16(GetKeyword(key1_change.sync_data())));
1265 ASSERT_TRUE(processor()->contains_guid("key2")); 1266 ASSERT_TRUE(processor()->contains_guid("key2"));
1266 syncer::SyncChange key2_change = processor()->change_for_guid("key2"); 1267 syncer::SyncChange key2_change = processor()->change_for_guid("key2");
1267 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, key2_change.change_type()); 1268 EXPECT_EQ(syncer::SyncChange::ACTION_UPDATE, key2_change.change_type());
1268 EXPECT_EQ(keyword2->keyword(), 1269 EXPECT_EQ(keyword2->keyword(),
1269 UTF8ToUTF16(GetKeyword(key2_change.sync_data()))); 1270 base::UTF8ToUTF16(GetKeyword(key2_change.sync_data())));
1270 } 1271 }
1271 1272
1272 TEST_F(TemplateURLServiceSyncTest, DuplicateEncodingsRemoved) { 1273 TEST_F(TemplateURLServiceSyncTest, DuplicateEncodingsRemoved) {
1273 // Create a sync entry with duplicate encodings. 1274 // Create a sync entry with duplicate encodings.
1274 syncer::SyncDataList initial_data; 1275 syncer::SyncDataList initial_data;
1275 1276
1276 TemplateURLData data; 1277 TemplateURLData data;
1277 data.short_name = ASCIIToUTF16("test"); 1278 data.short_name = ASCIIToUTF16("test");
1278 data.SetKeyword(ASCIIToUTF16("keyword")); 1279 data.SetKeyword(ASCIIToUTF16("keyword"));
1279 data.SetURL("http://test/%s"); 1280 data.SetURL("http://test/%s");
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 syncer::SyncMergeResult merge_result = model()->MergeDataAndStartSyncing( 2276 syncer::SyncMergeResult merge_result = model()->MergeDataAndStartSyncing(
2276 syncer::SEARCH_ENGINES, list, PassProcessor(), 2277 syncer::SEARCH_ENGINES, list, PassProcessor(),
2277 CreateAndPassSyncErrorFactory()); 2278 CreateAndPassSyncErrorFactory());
2278 2279
2279 const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default"); 2280 const TemplateURL* result_turl = model()->GetTemplateURLForGUID("default");
2280 EXPECT_TRUE(result_turl); 2281 EXPECT_TRUE(result_turl);
2281 EXPECT_EQ(default_turl->keyword(), result_turl->keyword()); 2282 EXPECT_EQ(default_turl->keyword(), result_turl->keyword());
2282 EXPECT_EQ(default_turl->short_name(), result_turl->short_name()); 2283 EXPECT_EQ(default_turl->short_name(), result_turl->short_name());
2283 EXPECT_EQ(default_turl->url(), result_turl->url()); 2284 EXPECT_EQ(default_turl->url(), result_turl->url());
2284 } 2285 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/search_engines/template_url_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698