| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/threading/thread.h" | 7 #include "base/threading/thread.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 9 #include "content/browser/gpu/shader_disk_cache.h" | 10 #include "content/browser/gpu/shader_disk_cache.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 11 #include "content/public/test/test_browser_thread_bundle.h" |
| 11 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const int kDefaultClientId = 42; | 18 const int kDefaultClientId = 42; |
| 18 const char kCacheKey[] = "key"; | 19 const char kCacheKey[] = "key"; |
| 19 const char kCacheValue[] = "cached value"; | 20 const char kCacheValue[] = "cached value"; |
| 20 | 21 |
| 21 } // namespace | 22 } // namespace |
| 22 | 23 |
| 23 class ShaderDiskCacheTest : public testing::Test { | 24 class ShaderDiskCacheTest : public testing::Test { |
| 24 public: | 25 public: |
| 25 ShaderDiskCacheTest() | 26 ShaderDiskCacheTest() |
| 26 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { | 27 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { |
| 28 ShaderCacheFactory::InitInstance( |
| 29 base::ThreadTaskRunnerHandle::Get(), |
| 30 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); |
| 27 } | 31 } |
| 28 | 32 |
| 29 ~ShaderDiskCacheTest() override {} | 33 ~ShaderDiskCacheTest() override {} |
| 30 | 34 |
| 31 const base::FilePath& cache_path() { return temp_dir_.GetPath(); } | 35 const base::FilePath& cache_path() { return temp_dir_.GetPath(); } |
| 32 | 36 |
| 33 void InitCache() { | 37 void InitCache() { |
| 34 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 38 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 35 ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId, | 39 ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId, |
| 36 cache_path()); | 40 cache_path()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 EXPECT_EQ(1, cache->Size()); | 71 EXPECT_EQ(1, cache->Size()); |
| 68 | 72 |
| 69 base::Time time; | 73 base::Time time; |
| 70 net::TestCompletionCallback clear_cb; | 74 net::TestCompletionCallback clear_cb; |
| 71 rv = cache->Clear(time, time, clear_cb.callback()); | 75 rv = cache->Clear(time, time, clear_cb.callback()); |
| 72 ASSERT_EQ(net::OK, clear_cb.GetResult(rv)); | 76 ASSERT_EQ(net::OK, clear_cb.GetResult(rv)); |
| 73 EXPECT_EQ(0, cache->Size()); | 77 EXPECT_EQ(0, cache->Size()); |
| 74 }; | 78 }; |
| 75 | 79 |
| 76 } // namespace content | 80 } // namespace content |
| OLD | NEW |