| OLD | NEW |
| 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 "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/sync/protocol/search_engine_specifics.pb.h" | 11 #include "chrome/browser/sync/protocol/search_engine_specifics.pb.h" |
| 12 #include "chrome/test/base/testing_browser_process_test.h" | |
| 13 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using base::Time; | 15 using base::Time; |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // Extract the GUID from a search engine SyncData. | 19 // Extract the GUID from a search engine SyncData. |
| 20 std::string GetGUID(const SyncData& sync_data) { | 20 std::string GetGUID(const SyncData& sync_data) { |
| 21 return sync_data.GetSpecifics().GetExtension( | 21 return sync_data.GetSpecifics().GetExtension( |
| 22 sync_pb::search_engine).sync_guid(); | 22 sync_pb::search_engine).sync_guid(); |
| 23 } | 23 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void set_erroneous(bool erroneous) { erroneous_ = erroneous; } | 72 void set_erroneous(bool erroneous) { erroneous_ = erroneous; } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 // Track the changes received in ProcessSyncChanges. | 75 // Track the changes received in ProcessSyncChanges. |
| 76 std::map<std::string, SyncChange> change_map_; | 76 std::map<std::string, SyncChange> change_map_; |
| 77 bool erroneous_; | 77 bool erroneous_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(TestChangeProcessor); | 79 DISALLOW_COPY_AND_ASSIGN(TestChangeProcessor); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 class TemplateURLServiceSyncTest : public TestingBrowserProcessTest { | 82 class TemplateURLServiceSyncTest : public testing::Test { |
| 83 public: | 83 public: |
| 84 typedef TemplateURLService::SyncDataMap SyncDataMap; | 84 typedef TemplateURLService::SyncDataMap SyncDataMap; |
| 85 | 85 |
| 86 TemplateURLServiceSyncTest() {} | 86 TemplateURLServiceSyncTest() {} |
| 87 | 87 |
| 88 virtual void SetUp() { | 88 virtual void SetUp() { |
| 89 profile_a_.reset(new TestingProfile); | 89 profile_a_.reset(new TestingProfile); |
| 90 model_a_.reset(new TemplateURLService(profile_a_.get())); | 90 model_a_.reset(new TemplateURLService(profile_a_.get())); |
| 91 model_a_->Load(); | 91 model_a_->Load(); |
| 92 profile_b_.reset(new TestingProfile); | 92 profile_b_.reset(new TestingProfile); |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 ASSERT_FALSE(error.IsSet()); | 973 ASSERT_FALSE(error.IsSet()); |
| 974 | 974 |
| 975 SyncChangeList changes; | 975 SyncChangeList changes; |
| 976 changes.push_back(CreateTestSyncChange( | 976 changes.push_back(CreateTestSyncChange( |
| 977 SyncChange::ACTION_UPDATE, | 977 SyncChange::ACTION_UPDATE, |
| 978 CreateTestTemplateURL("newkeyword", "http://new.com", "key2"))); | 978 CreateTestTemplateURL("newkeyword", "http://new.com", "key2"))); |
| 979 processor()->set_erroneous(true); | 979 processor()->set_erroneous(true); |
| 980 error = model()->ProcessSyncChanges(FROM_HERE, changes); | 980 error = model()->ProcessSyncChanges(FROM_HERE, changes); |
| 981 EXPECT_TRUE(error.IsSet()); | 981 EXPECT_TRUE(error.IsSet()); |
| 982 } | 982 } |
| OLD | NEW |