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

Side by Side Diff: components/sync/core_impl/protocol_event_buffer_unittest.cc

Issue 2284283002: Remove stl_util's STLElementDeleter from sync. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/core_impl/protocol_event_buffer.h" 5 #include "components/sync/core_impl/protocol_event_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/memory/scoped_vector.h"
13 #include "base/time/time.h" 12 #include "base/time/time.h"
14 #include "components/sync/engine/events/poll_get_updates_request_event.h" 13 #include "components/sync/engine/events/poll_get_updates_request_event.h"
15 #include "components/sync/engine/events/protocol_event.h" 14 #include "components/sync/engine/events/protocol_event.h"
16 #include "components/sync/protocol/sync.pb.h" 15 #include "components/sync/protocol/sync.pb.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 namespace syncer { 18 namespace syncer {
20 19
21 class ProtocolEventBufferTest : public ::testing::Test { 20 class ProtocolEventBufferTest : public ::testing::Test {
22 public: 21 public:
(...skipping 22 matching lines...) Expand all
45 return event.GetTimestamp() == base::Time::FromInternalValue(id); 44 return event.GetTimestamp() == base::Time::FromInternalValue(id);
46 } 45 }
47 46
48 TEST_F(ProtocolEventBufferTest, AddThenReturnEvents) { 47 TEST_F(ProtocolEventBufferTest, AddThenReturnEvents) {
49 std::unique_ptr<ProtocolEvent> e1(MakeTestEvent(1)); 48 std::unique_ptr<ProtocolEvent> e1(MakeTestEvent(1));
50 std::unique_ptr<ProtocolEvent> e2(MakeTestEvent(2)); 49 std::unique_ptr<ProtocolEvent> e2(MakeTestEvent(2));
51 50
52 buffer_.RecordProtocolEvent(*e1); 51 buffer_.RecordProtocolEvent(*e1);
53 buffer_.RecordProtocolEvent(*e2); 52 buffer_.RecordProtocolEvent(*e2);
54 53
55 ScopedVector<ProtocolEvent> buffered_events( 54 std::vector<std::unique_ptr<ProtocolEvent>> buffered_events(
56 buffer_.GetBufferedProtocolEvents()); 55 buffer_.GetBufferedProtocolEvents());
57 56
58 ASSERT_EQ(2U, buffered_events.size()); 57 ASSERT_EQ(2U, buffered_events.size());
59 EXPECT_TRUE(HasId(*(buffered_events[0]), 1)); 58 EXPECT_TRUE(HasId(*(buffered_events[0]), 1));
60 EXPECT_TRUE(HasId(*(buffered_events[1]), 2)); 59 EXPECT_TRUE(HasId(*(buffered_events[1]), 2));
61 } 60 }
62 61
63 TEST_F(ProtocolEventBufferTest, AddThenOverflowThenReturnEvents) { 62 TEST_F(ProtocolEventBufferTest, AddThenOverflowThenReturnEvents) {
64 for (size_t i = 0; i < ProtocolEventBuffer::kBufferSize + 1; ++i) { 63 for (size_t i = 0; i < ProtocolEventBuffer::kBufferSize + 1; ++i) {
65 std::unique_ptr<ProtocolEvent> e(MakeTestEvent(static_cast<int64_t>(i))); 64 std::unique_ptr<ProtocolEvent> e(MakeTestEvent(static_cast<int64_t>(i)));
66 buffer_.RecordProtocolEvent(*e); 65 buffer_.RecordProtocolEvent(*e);
67 } 66 }
68 67
69 ScopedVector<ProtocolEvent> buffered_events( 68 std::vector<std::unique_ptr<ProtocolEvent>> buffered_events(
70 buffer_.GetBufferedProtocolEvents()); 69 buffer_.GetBufferedProtocolEvents());
71 ASSERT_EQ(ProtocolEventBuffer::kBufferSize, buffered_events.size()); 70 ASSERT_EQ(ProtocolEventBuffer::kBufferSize, buffered_events.size());
72 71
73 for (size_t i = 1; i < ProtocolEventBuffer::kBufferSize + 1; ++i) { 72 for (size_t i = 1; i < ProtocolEventBuffer::kBufferSize + 1; ++i) {
74 EXPECT_TRUE(HasId(*(buffered_events[i - 1]), static_cast<int64_t>(i))); 73 EXPECT_TRUE(HasId(*(buffered_events[i - 1]), static_cast<int64_t>(i)));
75 } 74 }
76 } 75 }
77 76
78 } // namespace syncer 77 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/protocol_event_buffer.cc ('k') | components/sync/core_impl/sync_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698