Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: content/browser/gpu/shader_disk_cache_unittest.cc

Issue 12500009: Add the ability to clear the shader disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/shader_disk_cache.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/files/scoped_temp_dir.h"
6 #include "base/threading/thread.h"
7 #include "content/browser/browser_thread_impl.h"
8 #include "content/browser/gpu/shader_disk_cache.h"
9 #include "net/base/test_completion_callback.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace content {
13 namespace {
14
15 const int kDefaultClientId = 42;
16 const char kCacheKey[] = "key";
17 const char kCacheValue[] = "cached value";
18
19 } // namespace
20
21 class ShaderDiskCacheTest : public testing::Test {
22 public:
23 ShaderDiskCacheTest()
24 : cache_thread_(BrowserThread::CACHE, &message_loop_) {
25 }
26
27 virtual ~ShaderDiskCacheTest() {}
28
29 const base::FilePath& cache_path() { return temp_dir_.path(); }
30
31 void InitCache() {
32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
33 ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId,
34 cache_path());
35 }
36
37 private:
38 virtual void TearDown() OVERRIDE {
39 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
40 }
41
42 base::ScopedTempDir temp_dir_;
43 MessageLoopForIO message_loop_;
44 BrowserThreadImpl cache_thread_;
45
46 DISALLOW_COPY_AND_ASSIGN(ShaderDiskCacheTest);
47 };
48
49 TEST_F(ShaderDiskCacheTest, ClearsCache) {
50 InitCache();
51
52 scoped_refptr<ShaderDiskCache> cache =
53 ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
54 ASSERT_TRUE(cache.get() != NULL);
55
56 net::TestCompletionCallback available_cb;
57 int rv = cache->SetAvailableCallback(available_cb.callback());
58 ASSERT_EQ(net::OK, available_cb.GetResult(rv));
59 EXPECT_EQ(0, cache->Size());
60
61 cache->Cache(kCacheKey, kCacheValue);
62
63 net::TestCompletionCallback complete_cb;
64 rv = cache->SetCacheCompleteCallback(complete_cb.callback());
65 ASSERT_EQ(net::OK, complete_cb.GetResult(rv));
66 EXPECT_EQ(1, cache->Size());
67
68 base::Time time;
69 net::TestCompletionCallback clear_cb;
70 rv = cache->Clear(time, time, clear_cb.callback());
71 ASSERT_EQ(net::OK, clear_cb.GetResult(rv));
72 EXPECT_EQ(0, cache->Size());
73 };
74
75 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/shader_disk_cache.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698