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

Side by Side Diff: chrome/browser/sync/engine/cleanup_disabled_types_command_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698