OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/renderer_host/web_cache_manager.h" | 8 #include "components/web_cache/browser/web_cache_manager.h" |
9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 using base::Time; | 12 using base::Time; |
13 using base::TimeDelta; | 13 using base::TimeDelta; |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 using blink::WebCache; | 15 using blink::WebCache; |
16 | 16 |
17 namespace web_cache { | |
18 | |
17 class WebCacheManagerTest : public testing::Test { | 19 class WebCacheManagerTest : public testing::Test { |
18 protected: | 20 protected: |
19 typedef WebCacheManager::StatsMap StatsMap; | 21 typedef WebCacheManager::StatsMap StatsMap; |
20 typedef WebCacheManager::Allocation Allocation; | 22 typedef WebCacheManager::Allocation Allocation; |
21 typedef WebCacheManager::AllocationStrategy AllocationStrategy; | 23 typedef WebCacheManager::AllocationStrategy AllocationStrategy; |
22 | 24 |
23 static const int kRendererID; | 25 static const int kRendererID; |
24 static const int kRendererID2; | 26 static const int kRendererID2; |
25 static const WebCache::UsageStats kStats; | 27 static const WebCache::UsageStats kStats; |
26 static const WebCache::UsageStats kStats2; | 28 static const WebCache::UsageStats kStats2; |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 | 304 |
303 size_t expected_total_bytes = kExtraBytesToAllocate + | 305 size_t expected_total_bytes = kExtraBytesToAllocate + |
304 kStats.liveSize + kStats.deadSize + | 306 kStats.liveSize + kStats.deadSize + |
305 kStats2.liveSize + kStats2.deadSize; | 307 kStats2.liveSize + kStats2.deadSize; |
306 | 308 |
307 EXPECT_GE(expected_total_bytes, total_bytes); | 309 EXPECT_GE(expected_total_bytes, total_bytes); |
308 | 310 |
309 manager()->Remove(kRendererID); | 311 manager()->Remove(kRendererID); |
310 manager()->Remove(kRendererID2); | 312 manager()->Remove(kRendererID2); |
311 } | 313 } |
314 | |
315 TEST_F(WebCacheManagerTest, | |
316 RemoveRendererBeforeCallingObserveActivityShouldNotCrashTest) { | |
317 EXPECT_EQ(0U, active_renderers(manager()).size()); | |
318 EXPECT_EQ(0U, inactive_renderers(manager()).size()); | |
319 | |
320 scoped_ptr<base::Closure> test_call_back( | |
321 new base::Closure(base::MessageLoop::QuitWhenIdleClosure())); | |
322 manager()->SetTestCallback(test_call_back.Pass()); | |
323 | |
324 manager()->Add(kRendererID); | |
325 base::MessageLoop::current()->Run(); | |
326 manager()->Add(kRendererID2); | |
327 base::MessageLoop::current()->Run(); | |
328 | |
329 manager()->Remove(kRendererID); | |
330 base::MessageLoop::current()->Run(); | |
331 manager()->ObserveActivity(kRendererID); | |
332 | |
333 manager()->Remove(kRendererID2); | |
334 base::MessageLoop::current()->Run(); | |
erikwright (departed)
2014/09/10 15:49:43
Since the rest of this test suite is already using
Xi Han
2014/09/10 17:24:36
Done.
| |
335 } | |
336 | |
337 } // namespace web_cache | |
OLD | NEW |