OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "sync/internal_api/debug_info_event_listener.h" | 5 #include "components/sync/core_impl/debug_info_event_listener.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace syncer { | 9 namespace syncer { |
10 | 10 |
11 typedef testing::Test DebugInfoEventListenerTest; | 11 typedef testing::Test DebugInfoEventListenerTest; |
12 | 12 |
13 TEST_F(DebugInfoEventListenerTest, VerifyEventsAdded) { | 13 TEST_F(DebugInfoEventListenerTest, VerifyEventsAdded) { |
14 DebugInfoEventListener debug_info_event_listener; | 14 DebugInfoEventListener debug_info_event_listener; |
15 debug_info_event_listener.CreateAndAddEvent( | 15 debug_info_event_listener.CreateAndAddEvent( |
16 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); | 16 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); |
17 ASSERT_EQ(debug_info_event_listener.events_.size(), 1U); | 17 ASSERT_EQ(debug_info_event_listener.events_.size(), 1U); |
18 const sync_pb::DebugEventInfo& debug_info = | 18 const sync_pb::DebugEventInfo& debug_info = |
19 debug_info_event_listener.events_.back(); | 19 debug_info_event_listener.events_.back(); |
20 ASSERT_TRUE(debug_info.has_singleton_event()); | 20 ASSERT_TRUE(debug_info.has_singleton_event()); |
21 ASSERT_EQ(debug_info.singleton_event(), | 21 ASSERT_EQ(debug_info.singleton_event(), |
22 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); | 22 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); |
23 } | 23 } |
24 | 24 |
25 TEST_F(DebugInfoEventListenerTest, VerifyQueueSize) { | 25 TEST_F(DebugInfoEventListenerTest, VerifyQueueSize) { |
26 DebugInfoEventListener debug_info_event_listener; | 26 DebugInfoEventListener debug_info_event_listener; |
27 for (unsigned int i = 0; i < 2*kMaxEntries; ++i) { | 27 for (unsigned int i = 0; i < 2 * kMaxEntries; ++i) { |
28 debug_info_event_listener.CreateAndAddEvent( | 28 debug_info_event_listener.CreateAndAddEvent( |
29 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); | 29 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); |
30 } | 30 } |
31 sync_pb::DebugInfo debug_info; | 31 sync_pb::DebugInfo debug_info; |
32 debug_info_event_listener.GetDebugInfo(&debug_info); | 32 debug_info_event_listener.GetDebugInfo(&debug_info); |
33 debug_info_event_listener.ClearDebugInfo(); | 33 debug_info_event_listener.ClearDebugInfo(); |
34 ASSERT_TRUE(debug_info.events_dropped()); | 34 ASSERT_TRUE(debug_info.events_dropped()); |
35 ASSERT_EQ(static_cast<int>(kMaxEntries), debug_info.events_size()); | 35 ASSERT_EQ(static_cast<int>(kMaxEntries), debug_info.events_size()); |
36 } | 36 } |
37 | 37 |
(...skipping 14 matching lines...) Expand all Loading... |
52 TEST_F(DebugInfoEventListenerTest, VerifyClearEvents) { | 52 TEST_F(DebugInfoEventListenerTest, VerifyClearEvents) { |
53 DebugInfoEventListener debug_info_event_listener; | 53 DebugInfoEventListener debug_info_event_listener; |
54 debug_info_event_listener.CreateAndAddEvent( | 54 debug_info_event_listener.CreateAndAddEvent( |
55 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); | 55 sync_pb::SyncEnums::ENCRYPTION_COMPLETE); |
56 ASSERT_EQ(debug_info_event_listener.events_.size(), 1U); | 56 ASSERT_EQ(debug_info_event_listener.events_.size(), 1U); |
57 debug_info_event_listener.ClearDebugInfo(); | 57 debug_info_event_listener.ClearDebugInfo(); |
58 ASSERT_EQ(debug_info_event_listener.events_.size(), 0U); | 58 ASSERT_EQ(debug_info_event_listener.events_.size(), 0U); |
59 } | 59 } |
60 | 60 |
61 } // namespace syncer | 61 } // namespace syncer |
OLD | NEW |