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

Side by Side Diff: blimp/helium/lazy_syncable_adapter_unittest.cc

Issue 2602103002: Delete blimp/helium and remove references to it from dependent targets (Closed)
Patch Set: . Created 3 years, 11 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
« no previous file with comments | « blimp/helium/lazy_syncable_adapter.h ('k') | blimp/helium/lww_register.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "blimp/helium/lazy_syncable_adapter.h"
6
7 #include <stdint.h>
8
9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h"
11 #include "blimp/helium/helium_test.h"
12 #include "blimp/helium/mock_objects.h"
13 #include "blimp/helium/serializable_struct.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 using testing::_;
18 using testing::DoAll;
19 using testing::Return;
20 using testing::SaveArg;
21
22 namespace blimp {
23 namespace helium {
24 namespace {
25
26 constexpr Revision kRevision = 42;
27
28 class LazySyncableAdapterTest : public HeliumTest {
29 public:
30 LazySyncableAdapterTest() : adapter_(&syncable_) {}
31 ~LazySyncableAdapterTest() override = default;
32
33 MOCK_METHOD0(CallbackMock, void());
34
35 protected:
36 MockSyncable syncable_;
37 LazySyncableAdapter<TestSyncableChangeset> adapter_;
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(LazySyncableAdapterTest);
41 };
42
43 TEST_F(LazySyncableAdapterTest, ForwardsSetLocalCallback) {
44 base::Closure callback_arg;
45
46 EXPECT_CALL(syncable_, SetLocalUpdateCallback(_))
47 .WillOnce(SaveArg<0>(&callback_arg));
48 adapter_.SetLocalUpdateCallback(base::Bind(
49 &LazySyncableAdapterTest::CallbackMock, base::Unretained(this)));
50
51 EXPECT_CALL(*this, CallbackMock());
52 callback_arg.Run();
53 }
54
55 TEST_F(LazySyncableAdapterTest, ForwardsReleaseBefore) {
56 EXPECT_CALL(syncable_, ReleaseBefore(kRevision));
57 adapter_.ReleaseBefore(kRevision);
58 }
59
60 TEST_F(LazySyncableAdapterTest, ForwardsGetRevision) {
61 EXPECT_CALL(syncable_, GetRevision()).WillOnce(Return(kRevision));
62 EXPECT_EQ(kRevision, adapter_.GetRevision());
63 }
64
65 TEST_F(LazySyncableAdapterTest, ForwardsPrepareToCreateChangeset) {
66 base::Closure callback_arg;
67
68 EXPECT_CALL(syncable_, PrepareToCreateChangeset(kRevision, _))
69 .WillOnce(SaveArg<1>(&callback_arg));
70 adapter_.PrepareToCreateChangeset(
71 kRevision, base::Bind(&LazySyncableAdapterTest::CallbackMock,
72 base::Unretained(this)));
73
74 EXPECT_CALL(*this, CallbackMock());
75 callback_arg.Run();
76 }
77
78 TEST_F(LazySyncableAdapterTest, SerializesParsesForwardsChangesets) {
79 std::unique_ptr<TestSyncableChangeset> changeset =
80 base::MakeUnique<TestSyncableChangeset>();
81 changeset->value.Set(33);
82
83 EXPECT_CALL(syncable_, CreateChangesetMock(kRevision))
84 .WillOnce(Return(changeset.release()));
85 std::unique_ptr<std::string> string_changeset =
86 adapter_.CreateChangeset(kRevision);
87
88 TestSyncableChangeset validate_changeset;
89 EXPECT_CALL(syncable_, ValidateChangeset(_))
90 .WillOnce(DoAll(SaveArg<0>(&validate_changeset), Return(true)));
91 EXPECT_EQ(true, adapter_.ValidateChangeset(*string_changeset));
92 EXPECT_EQ(33, validate_changeset.value());
93
94 TestSyncableChangeset apply_changeset;
95 EXPECT_CALL(syncable_, ApplyChangeset(_))
96 .WillOnce(SaveArg<0>(&apply_changeset));
97 adapter_.ApplyChangeset(*string_changeset);
98 EXPECT_EQ(33, apply_changeset.value());
99 }
100
101 } // namespace
102 } // namespace helium
103 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/helium/lazy_syncable_adapter.h ('k') | blimp/helium/lww_register.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698