| OLD | NEW |
| 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_driver/tab_node_pool.h" | 5 #include "components/sync_sessions/tab_node_pool.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "sync/api/sync_change.h" | 9 #include "sync/api/sync_change.h" |
| 10 #include "sync/protocol/session_specifics.pb.h" | 10 #include "sync/protocol/session_specifics.pb.h" |
| 11 #include "sync/protocol/sync.pb.h" | 11 #include "sync/protocol/sync.pb.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace browser_sync { | 14 namespace browser_sync { |
| 15 | 15 |
| 16 class SyncTabNodePoolTest : public testing::Test { | 16 class SyncTabNodePoolTest : public testing::Test { |
| 17 protected: | 17 protected: |
| 18 SyncTabNodePoolTest() { pool_.SetMachineTag("tag"); } | 18 SyncTabNodePoolTest() { pool_.SetMachineTag("tag"); } |
| 19 | 19 |
| 20 int GetMaxUsedTabNodeId() const { return pool_.max_used_tab_node_id_; } | 20 int GetMaxUsedTabNodeId() const { return pool_.max_used_tab_node_id_; } |
| 21 | 21 |
| 22 void AddFreeTabNodes(size_t size, const int node_ids[]); | 22 void AddFreeTabNodes(size_t size, const int node_ids[]); |
| 23 | 23 |
| 24 TabNodePool pool_; | 24 TabNodePool pool_; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 void SyncTabNodePoolTest::AddFreeTabNodes( | 27 void SyncTabNodePoolTest::AddFreeTabNodes(size_t size, const int node_ids[]) { |
| 28 size_t size, const int node_ids[]) { | |
| 29 for (size_t i = 0; i < size; ++i) { | 28 for (size_t i = 0; i < size; ++i) { |
| 30 pool_.free_nodes_pool_.insert(node_ids[i]); | 29 pool_.free_nodes_pool_.insert(node_ids[i]); |
| 31 } | 30 } |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace { | 33 namespace { |
| 35 | 34 |
| 36 TEST_F(SyncTabNodePoolTest, TabNodeIdIncreases) { | 35 TEST_F(SyncTabNodePoolTest, TabNodeIdIncreases) { |
| 37 syncer::SyncChangeList changes; | 36 syncer::SyncChangeList changes; |
| 38 // max_used_tab_node_ always increases. | 37 // max_used_tab_node_ always increases. |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // kFreeNodesLowWatermark. | 253 // kFreeNodesLowWatermark. |
| 255 pool_.FreeTabNode(last_sync_id, &changes); | 254 pool_.FreeTabNode(last_sync_id, &changes); |
| 256 EXPECT_FALSE(pool_.Empty()); | 255 EXPECT_FALSE(pool_.Empty()); |
| 257 EXPECT_TRUE(pool_.Full()); | 256 EXPECT_TRUE(pool_.Full()); |
| 258 EXPECT_EQ(TabNodePool::kFreeNodesLowWatermark, pool_.Capacity()); | 257 EXPECT_EQ(TabNodePool::kFreeNodesLowWatermark, pool_.Capacity()); |
| 259 } | 258 } |
| 260 | 259 |
| 261 } // namespace | 260 } // namespace |
| 262 | 261 |
| 263 } // namespace browser_sync | 262 } // namespace browser_sync |
| OLD | NEW |