OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <vector> | |
6 | |
7 #include "sync/engine/cleanup_disabled_types_command.h" | |
8 | |
9 #include "sync/internal_api/public/base/model_type_test_util.h" | |
10 #include "sync/sessions/sync_session.h" | |
11 #include "sync/test/engine/syncer_command_test.h" | |
12 #include "testing/gmock/include/gmock/gmock.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 namespace syncer { | |
16 | |
17 namespace { | |
18 | |
19 using testing::_; | |
20 | |
21 class CleanupDisabledTypesCommandTest : public MockDirectorySyncerCommandTest { | |
22 public: | |
23 CleanupDisabledTypesCommandTest() {} | |
24 | |
25 virtual void SetUp() { | |
26 mutable_routing_info()->clear(); | |
27 (*mutable_routing_info())[BOOKMARKS] = GROUP_PASSIVE; | |
28 MockDirectorySyncerCommandTest::SetUp(); | |
29 } | |
30 }; | |
31 | |
32 // TODO(tim): Add syncer test to verify previous routing info is set. | |
33 TEST_F(CleanupDisabledTypesCommandTest, NoPreviousRoutingInfo) { | |
34 CleanupDisabledTypesCommand command; | |
35 ModelTypeSet expected = ModelTypeSet::All(); | |
36 expected.Remove(BOOKMARKS); | |
37 EXPECT_CALL(*mock_directory(), | |
38 PurgeEntriesWithTypeIn(HasModelTypes(expected))); | |
39 command.ExecuteImpl(session()); | |
40 } | |
41 | |
42 TEST_F(CleanupDisabledTypesCommandTest, NoPurge) { | |
43 CleanupDisabledTypesCommand command; | |
44 EXPECT_CALL(*mock_directory(), PurgeEntriesWithTypeIn(_)).Times(0); | |
45 | |
46 ModelSafeRoutingInfo prev(routing_info()); | |
47 session()->context()->set_previous_session_routing_info(prev); | |
48 (*mutable_routing_info())[AUTOFILL] = GROUP_PASSIVE; | |
49 command.ExecuteImpl(session()); | |
50 | |
51 prev = routing_info(); | |
52 command.ExecuteImpl(session()); | |
53 } | |
54 | |
55 TEST_F(CleanupDisabledTypesCommandTest, TypeDisabled) { | |
56 CleanupDisabledTypesCommand command; | |
57 | |
58 (*mutable_routing_info())[AUTOFILL] = GROUP_PASSIVE; | |
59 (*mutable_routing_info())[THEMES] = GROUP_PASSIVE; | |
60 (*mutable_routing_info())[EXTENSIONS] = GROUP_PASSIVE; | |
61 | |
62 ModelSafeRoutingInfo prev(routing_info()); | |
63 prev[PASSWORDS] = GROUP_PASSIVE; | |
64 prev[PREFERENCES] = GROUP_PASSIVE; | |
65 session()->context()->set_previous_session_routing_info(prev); | |
66 | |
67 const ModelTypeSet expected(PASSWORDS, PREFERENCES); | |
68 EXPECT_CALL(*mock_directory(), | |
69 PurgeEntriesWithTypeIn(HasModelTypes(expected))); | |
70 command.ExecuteImpl(session()); | |
71 } | |
72 | |
73 } // namespace | |
74 | |
75 } // namespace syncer | |
OLD | NEW |