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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" | |
10 #include "chrome/browser/sync/engine/process_commit_response_command.h" | 9 #include "chrome/browser/sync/engine/process_commit_response_command.h" |
11 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
12 #include "chrome/browser/sync/protocol/sync.pb.h" | 11 #include "chrome/browser/sync/protocol/sync.pb.h" |
13 #include "chrome/browser/sync/sessions/sync_session.h" | 12 #include "chrome/browser/sync/sessions/sync_session.h" |
14 #include "chrome/browser/sync/syncable/directory_manager.h" | 13 #include "chrome/browser/sync/syncable/directory_manager.h" |
15 #include "chrome/browser/sync/syncable/syncable.h" | 14 #include "chrome/browser/sync/syncable/syncable.h" |
16 #include "chrome/browser/sync/syncable/syncable_id.h" | 15 #include "chrome/browser/sync/syncable/syncable_id.h" |
| 16 #include "chrome/browser/sync/test/engine/fake_model_worker.h" |
17 #include "chrome/browser/sync/test/engine/syncer_command_test.h" | 17 #include "chrome/browser/sync/test/engine/syncer_command_test.h" |
18 #include "chrome/browser/sync/test/engine/test_id_factory.h" | 18 #include "chrome/browser/sync/test/engine/test_id_factory.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace browser_sync { | 21 namespace browser_sync { |
22 | 22 |
23 using sessions::SyncSession; | 23 using sessions::SyncSession; |
24 using std::string; | 24 using std::string; |
25 using syncable::BASE_VERSION; | 25 using syncable::BASE_VERSION; |
26 using syncable::Entry; | 26 using syncable::Entry; |
27 using syncable::IS_DIR; | 27 using syncable::IS_DIR; |
28 using syncable::IS_UNSYNCED; | 28 using syncable::IS_UNSYNCED; |
29 using syncable::Id; | 29 using syncable::Id; |
30 using syncable::MutableEntry; | 30 using syncable::MutableEntry; |
31 using syncable::NON_UNIQUE_NAME; | 31 using syncable::NON_UNIQUE_NAME; |
32 using syncable::ReadTransaction; | 32 using syncable::ReadTransaction; |
33 using syncable::ScopedDirLookup; | 33 using syncable::ScopedDirLookup; |
34 using syncable::UNITTEST; | 34 using syncable::UNITTEST; |
35 using syncable::WriteTransaction; | 35 using syncable::WriteTransaction; |
36 | 36 |
37 // A test fixture for tests exercising ProcessCommitResponseCommand. | 37 // A test fixture for tests exercising ProcessCommitResponseCommand. |
38 template<typename T> | 38 template<typename T> |
39 class ProcessCommitResponseCommandTestWithParam | 39 class ProcessCommitResponseCommandTestWithParam |
40 : public SyncerCommandTestWithParam<T> { | 40 : public SyncerCommandTestWithParam<T> { |
41 public: | 41 public: |
42 virtual void SetUp() { | 42 virtual void SetUp() { |
43 workers()->clear(); | 43 workers()->clear(); |
44 mutable_routing_info()->clear(); | 44 mutable_routing_info()->clear(); |
45 | 45 |
46 // GROUP_PASSIVE worker. | 46 workers()->push_back( |
47 workers()->push_back(make_scoped_refptr(new ModelSafeWorker())); | 47 make_scoped_refptr(new FakeModelWorker(GROUP_DB))); |
48 // GROUP_UI worker. | 48 workers()->push_back( |
49 workers()->push_back(make_scoped_refptr(new MockUIModelWorker())); | 49 make_scoped_refptr(new FakeModelWorker(GROUP_UI))); |
50 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; | 50 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI; |
51 (*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI; | 51 (*mutable_routing_info())[syncable::PREFERENCES] = GROUP_UI; |
52 (*mutable_routing_info())[syncable::AUTOFILL] = GROUP_PASSIVE; | 52 (*mutable_routing_info())[syncable::AUTOFILL] = GROUP_DB; |
53 | 53 |
54 commit_set_.reset(new sessions::OrderedCommitSet(routing_info())); | 54 commit_set_.reset(new sessions::OrderedCommitSet(routing_info())); |
55 SyncerCommandTestWithParam<T>::SetUp(); | 55 SyncerCommandTestWithParam<T>::SetUp(); |
56 } | 56 } |
57 | 57 |
58 protected: | 58 protected: |
59 using SyncerCommandTestWithParam<T>::context; | 59 using SyncerCommandTestWithParam<T>::context; |
60 using SyncerCommandTestWithParam<T>::mutable_routing_info; | 60 using SyncerCommandTestWithParam<T>::mutable_routing_info; |
61 using SyncerCommandTestWithParam<T>::routing_info; | 61 using SyncerCommandTestWithParam<T>::routing_info; |
62 using SyncerCommandTestWithParam<T>::session; | 62 using SyncerCommandTestWithParam<T>::session; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); | 439 EXPECT_EQ(2049U, final_monitor_records["ABC"].bookmark_write_count); |
440 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); | 440 EXPECT_EQ(4U, final_monitor_records["xyz"].bookmark_write_count); |
441 } else { | 441 } else { |
442 EXPECT_TRUE(final_monitor_records.empty()) | 442 EXPECT_TRUE(final_monitor_records.empty()) |
443 << "Should not restore records after successful bookmark commit."; | 443 << "Should not restore records after successful bookmark commit."; |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 | 447 |
448 } // namespace browser_sync | 448 } // namespace browser_sync |
OLD | NEW |