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

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

Issue 8637006: [Sync] Make syncer commands avoid posting tasks on threads with no work to do (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head, fix windows compile Created 9 years 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 "base/basictypes.h"
6 #include "base/compiler_specific.h"
7 #include "base/memory/ref_counted.h"
8 #include "chrome/browser/sync/engine/model_changing_syncer_command.h"
9 #include "chrome/browser/sync/sessions/sync_session.h"
10 #include "chrome/browser/sync/syncable/model_type.h"
11 #include "chrome/browser/sync/test/engine/fake_model_worker.h"
12 #include "chrome/browser/sync/test/engine/syncer_command_test.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace browser_sync {
16
17 namespace {
18
19 class FakeModelChangingSyncerCommand : public ModelChangingSyncerCommand {
20 public:
21 FakeModelChangingSyncerCommand() {}
22 virtual ~FakeModelChangingSyncerCommand() {}
23
24 const std::set<ModelSafeGroup>& changed_groups() const {
25 return changed_groups_;
26 }
27
28 protected:
29 virtual bool HasCustomGroupsToChange() const OVERRIDE {
30 return false;
31 }
32
33 virtual std::set<ModelSafeGroup> GetGroupsToChange(
34 const sessions::SyncSession& session) const OVERRIDE {
35 return session.GetEnabledGroups();
36 }
37
38 virtual void ModelChangingExecuteImpl(
39 sessions::SyncSession* session) OVERRIDE {
40 changed_groups_.insert(session->status_controller().group_restriction());
41 }
42
43 private:
44 std::set<ModelSafeGroup> changed_groups_;
45
46 DISALLOW_COPY_AND_ASSIGN(FakeModelChangingSyncerCommand);
47 };
48
49 class ModelChangingSyncerCommandTest : public SyncerCommandTest {
50 protected:
51 ModelChangingSyncerCommandTest() {}
52 virtual ~ModelChangingSyncerCommandTest() {}
53
54 virtual void SetUp() {
55 workers()->push_back(
56 make_scoped_refptr(new FakeModelWorker(GROUP_UI)));
57 workers()->push_back(
58 make_scoped_refptr(new FakeModelWorker(GROUP_PASSWORD)));
59 (*mutable_routing_info())[syncable::BOOKMARKS] = GROUP_UI;
60 (*mutable_routing_info())[syncable::PASSWORDS] = GROUP_PASSWORD;
61 SyncerCommandTest::SetUp();
62 }
63
64 FakeModelChangingSyncerCommand command_;
65
66 private:
67 DISALLOW_COPY_AND_ASSIGN(ModelChangingSyncerCommandTest);
68 };
69
70 TEST_F(ModelChangingSyncerCommandTest, Basic) {
71 ExpectGroupsToChange(command_, GROUP_UI, GROUP_PASSWORD, GROUP_PASSIVE);
72 EXPECT_TRUE(command_.changed_groups().empty());
73 command_.ExecuteImpl(session());
74 EXPECT_EQ(command_.GetGroupsToChangeForTest(*session()),
75 command_.changed_groups());
76 }
77
78 } // namespace
79
80 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698