OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/json/json_string_value_serializer.h" | 6 #include "base/json/json_string_value_serializer.h" |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const char kUnsyncedPreferenceDefaultValue[] = "default"; | 35 const char kUnsyncedPreferenceDefaultValue[] = "default"; |
36 const char kNonDefaultCharsetValue[] = "foo"; | 36 const char kNonDefaultCharsetValue[] = "foo"; |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 class TestSyncProcessorStub : public syncer::SyncChangeProcessor { | 39 class TestSyncProcessorStub : public syncer::SyncChangeProcessor { |
40 public: | 40 public: |
41 explicit TestSyncProcessorStub(syncer::SyncChangeList* output) | 41 explicit TestSyncProcessorStub(syncer::SyncChangeList* output) |
42 : output_(output), fail_next_(false) {} | 42 : output_(output), fail_next_(false) {} |
43 virtual syncer::SyncError ProcessSyncChanges( | 43 virtual syncer::SyncError ProcessSyncChanges( |
44 const tracked_objects::Location& from_here, | 44 const tracked_objects::Location& from_here, |
45 const syncer::SyncChangeList& change_list) OVERRIDE { | 45 const syncer::SyncChangeList& change_list) override { |
46 if (output_) | 46 if (output_) |
47 output_->insert(output_->end(), change_list.begin(), change_list.end()); | 47 output_->insert(output_->end(), change_list.begin(), change_list.end()); |
48 if (fail_next_) { | 48 if (fail_next_) { |
49 fail_next_ = false; | 49 fail_next_ = false; |
50 return syncer::SyncError( | 50 return syncer::SyncError( |
51 FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Error", | 51 FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Error", |
52 syncer::PREFERENCES); | 52 syncer::PREFERENCES); |
53 } | 53 } |
54 return syncer::SyncError(); | 54 return syncer::SyncError(); |
55 } | 55 } |
56 | 56 |
57 void FailNextProcessSyncChanges() { | 57 void FailNextProcessSyncChanges() { |
58 fail_next_ = true; | 58 fail_next_ = true; |
59 } | 59 } |
60 | 60 |
61 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) | 61 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) |
62 const OVERRIDE { | 62 const override { |
63 return syncer::SyncDataList(); | 63 return syncer::SyncDataList(); |
64 } | 64 } |
65 private: | 65 private: |
66 syncer::SyncChangeList* output_; | 66 syncer::SyncChangeList* output_; |
67 bool fail_next_; | 67 bool fail_next_; |
68 }; | 68 }; |
69 | 69 |
70 class PrefsSyncableServiceTest : public testing::Test { | 70 class PrefsSyncableServiceTest : public testing::Test { |
71 public: | 71 public: |
72 PrefsSyncableServiceTest() : | 72 PrefsSyncableServiceTest() : |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 | 715 |
716 InitWithNoSyncData(); | 716 InitWithNoSyncData(); |
717 | 717 |
718 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 718 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
719 syncer::SyncChangeList list; | 719 syncer::SyncChangeList list; |
720 list.push_back(MakeRemoteChange( | 720 list.push_back(MakeRemoteChange( |
721 1, prefs::kHomePage, *null_value, SyncChange::ACTION_DELETE)); | 721 1, prefs::kHomePage, *null_value, SyncChange::ACTION_DELETE)); |
722 pref_sync_service_->ProcessSyncChanges(FROM_HERE, list); | 722 pref_sync_service_->ProcessSyncChanges(FROM_HERE, list); |
723 EXPECT_TRUE(pref->IsDefaultValue()); | 723 EXPECT_TRUE(pref->IsDefaultValue()); |
724 } | 724 } |
OLD | NEW |