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/message_loop/message_loop_proxy.h" | 6 #include "base/message_loop/message_loop_proxy.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/gpu/shader_disk_cache.h" | 10 #include "content/browser/gpu/shader_disk_cache.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 cache_->Cache(kCacheKey, kCacheValue); | 78 cache_->Cache(kCacheKey, kCacheValue); |
79 | 79 |
80 net::TestCompletionCallback complete_cb; | 80 net::TestCompletionCallback complete_cb; |
81 | 81 |
82 rv = cache_->SetCacheCompleteCallback(complete_cb.callback()); | 82 rv = cache_->SetCacheCompleteCallback(complete_cb.callback()); |
83 ASSERT_EQ(net::OK, complete_cb.GetResult(rv)); | 83 ASSERT_EQ(net::OK, complete_cb.GetResult(rv)); |
84 } | 84 } |
85 | 85 |
86 size_t Size() { return cache_->Size(); } | 86 size_t Size() { return cache_->Size(); } |
87 | 87 |
88 MessageLoop* message_loop() { return &message_loop_; } | 88 base::MessageLoop* message_loop() { return &message_loop_; } |
89 | 89 |
90 private: | 90 private: |
91 virtual void TearDown() OVERRIDE { | 91 virtual void TearDown() OVERRIDE { |
92 cache_ = NULL; | 92 cache_ = NULL; |
93 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId); | 93 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId); |
94 } | 94 } |
95 | 95 |
96 base::ScopedTempDir temp_dir_; | 96 base::ScopedTempDir temp_dir_; |
97 MessageLoopForIO message_loop_; | 97 base::MessageLoopForIO message_loop_; |
98 TestBrowserThread ui_thread_; | 98 TestBrowserThread ui_thread_; |
99 TestBrowserThread cache_thread_; | 99 TestBrowserThread cache_thread_; |
100 TestBrowserThread io_thread_; | 100 TestBrowserThread io_thread_; |
101 | 101 |
102 scoped_refptr<ShaderDiskCache> cache_; | 102 scoped_refptr<ShaderDiskCache> cache_; |
103 }; | 103 }; |
104 | 104 |
105 void ClearData(content::StoragePartitionImpl* sp, | 105 void ClearData(content::StoragePartitionImpl* sp, |
106 const base::Closure& cb) { | 106 const base::Closure& cb) { |
107 base::Time time; | 107 base::Time time; |
108 sp->AsyncClearDataBetween(content::StoragePartition::kShaderStorage, | 108 sp->AsyncClearDataBetween(content::StoragePartition::kShaderStorage, |
109 time, time, cb); | 109 time, time, cb); |
110 } | 110 } |
111 | 111 |
112 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { | 112 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { |
113 InitCache(); | 113 InitCache(); |
114 EXPECT_EQ(1u, Size()); | 114 EXPECT_EQ(1u, Size()); |
115 | 115 |
116 TestClosureCallback clear_cb; | 116 TestClosureCallback clear_cb; |
117 StoragePartitionImpl sp(cache_path(), NULL, NULL, NULL, NULL, NULL, NULL); | 117 StoragePartitionImpl sp(cache_path(), NULL, NULL, NULL, NULL, NULL, NULL); |
118 message_loop()->PostTask(FROM_HERE, | 118 message_loop()->PostTask(FROM_HERE, |
119 base::Bind(&ClearData, &sp, clear_cb.callback())); | 119 base::Bind(&ClearData, &sp, clear_cb.callback())); |
120 clear_cb.WaitForResult(); | 120 clear_cb.WaitForResult(); |
121 EXPECT_EQ(0u, Size()); | 121 EXPECT_EQ(0u, Size()); |
122 } | 122 } |
123 | 123 |
124 } // namespace content | 124 } // namespace content |
OLD | NEW |