More bring up of ui code on iOS.
[chromium-blink-merge.git] / sync / engine / model_changing_syncer_command_unittest.cc
blob867f93ea1ba0dce10672ce6ac46961593dd70ebc
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.
5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "base/memory/ref_counted.h"
8 #include "sync/engine/model_changing_syncer_command.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/sessions/sync_session.h"
11 #include "sync/test/engine/fake_model_worker.h"
12 #include "sync/test/engine/syncer_command_test.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 namespace syncer {
17 namespace {
19 class FakeModelChangingSyncerCommand : public ModelChangingSyncerCommand {
20 public:
21 FakeModelChangingSyncerCommand() {}
22 virtual ~FakeModelChangingSyncerCommand() {}
24 const std::set<ModelSafeGroup>& changed_groups() const {
25 return changed_groups_;
28 protected:
29 virtual std::set<ModelSafeGroup> GetGroupsToChange(
30 const sessions::SyncSession& session) const OVERRIDE {
31 return session.GetEnabledGroups();
34 virtual SyncerError ModelChangingExecuteImpl(
35 sessions::SyncSession* session) OVERRIDE {
36 changed_groups_.insert(session->status_controller().group_restriction());
37 return SYNCER_OK;
40 private:
41 std::set<ModelSafeGroup> changed_groups_;
43 DISALLOW_COPY_AND_ASSIGN(FakeModelChangingSyncerCommand);
46 class ModelChangingSyncerCommandTest : public SyncerCommandTest {
47 protected:
48 ModelChangingSyncerCommandTest() {}
49 virtual ~ModelChangingSyncerCommandTest() {}
51 virtual void SetUp() {
52 workers()->push_back(
53 make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
54 workers()->push_back(
55 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD)));
56 (*mutable_routing_info())[BOOKMARKS] = GROUP_UI;
57 (*mutable_routing_info())[PASSWORDS] = GROUP_PASSWORD;
58 SyncerCommandTest::SetUp();
61 FakeModelChangingSyncerCommand command_;
63 private:
64 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommandTest);
67 TEST_F(ModelChangingSyncerCommandTest, Basic) {
68 ExpectGroupsToChange(command_, GROUP_UI, GROUP_PASSWORD, GROUP_PASSIVE);
69 EXPECT_TRUE(command_.changed_groups().empty());
70 command_.ExecuteImpl(session());
71 EXPECT_EQ(command_.GetGroupsToChangeForTest(*session()),
72 command_.changed_groups());
75 } // namespace
77 } // namespace syncer