| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include "android_webview/browser/global_tile_manager.h" | 6 #include "android_webview/browser/global_tile_manager.h" |
| 7 #include "android_webview/browser/global_tile_manager_client.h" | 7 #include "android_webview/browser/global_tile_manager_client.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 // This should be the same as the one defined global_tile_manager.cc | 11 // This should be the same as the one defined global_tile_manager.cc |
| 12 const size_t kNumTilesLimit = 450; | 12 const size_t kNumTilesLimit = 450; |
| 13 const size_t kDefaultNumTiles = 150; | 13 const size_t kDefaultNumTiles = 150; |
| 14 | 14 |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 using android_webview::GlobalTileManager; | 17 using android_webview::GlobalTileManager; |
| 18 using android_webview::GlobalTileManagerClient; | 18 using android_webview::GlobalTileManagerClient; |
| 19 using content::SynchronousCompositorMemoryPolicy; | 19 using content::SynchronousCompositorMemoryPolicy; |
| 20 using testing::Test; | 20 using testing::Test; |
| 21 | 21 |
| 22 class MockGlobalTileManagerClient : public GlobalTileManagerClient { | 22 class MockGlobalTileManagerClient : public GlobalTileManagerClient { |
| 23 public: | 23 public: |
| 24 virtual SynchronousCompositorMemoryPolicy GetMemoryPolicy() const OVERRIDE { | 24 virtual SynchronousCompositorMemoryPolicy GetMemoryPolicy() const override { |
| 25 return memory_policy_; | 25 return memory_policy_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void SetMemoryPolicy(SynchronousCompositorMemoryPolicy new_policy, | 28 virtual void SetMemoryPolicy(SynchronousCompositorMemoryPolicy new_policy, |
| 29 bool effective_immediately) OVERRIDE { | 29 bool effective_immediately) override { |
| 30 memory_policy_ = new_policy; | 30 memory_policy_ = new_policy; |
| 31 } | 31 } |
| 32 | 32 |
| 33 MockGlobalTileManagerClient() { | 33 MockGlobalTileManagerClient() { |
| 34 tile_request_.num_resources_limit = kDefaultNumTiles; | 34 tile_request_.num_resources_limit = kDefaultNumTiles; |
| 35 key_ = GlobalTileManager::GetInstance()->PushBack(this); | 35 key_ = GlobalTileManager::GetInstance()->PushBack(this); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual ~MockGlobalTileManagerClient() { | 38 virtual ~MockGlobalTileManagerClient() { |
| 39 GlobalTileManager::GetInstance()->Remove(key_); | 39 GlobalTileManager::GetInstance()->Remove(key_); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 for (size_t i = 0; i < 10; i++) { | 156 for (size_t i = 0; i < 10; i++) { |
| 157 EXPECT_EQ(clients[i].GetMemoryPolicy().num_resources_limit, | 157 EXPECT_EQ(clients[i].GetMemoryPolicy().num_resources_limit, |
| 158 kNumTilesLimit / 10); | 158 kNumTilesLimit / 10); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Ensure that the inactive tiles are evicted. | 161 // Ensure that the inactive tiles are evicted. |
| 162 for (size_t i = 11; i < 20; i++) { | 162 for (size_t i = 11; i < 20; i++) { |
| 163 EXPECT_EQ(clients[i].GetMemoryPolicy().num_resources_limit, 0u); | 163 EXPECT_EQ(clients[i].GetMemoryPolicy().num_resources_limit, 0u); |
| 164 } | 164 } |
| 165 } | 165 } |
| OLD | NEW |