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

Side by Side Diff: webkit/appcache/appcache_storage_unittest.cc

Issue 10066044: RefCounted types should not have public destructors, webkit/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation ordering Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "webkit/appcache/appcache.h" 7 #include "webkit/appcache/appcache.h"
8 #include "webkit/appcache/appcache_group.h" 8 #include "webkit/appcache/appcache_group.h"
9 #include "webkit/appcache/appcache_response.h" 9 #include "webkit/appcache/appcache_response.h"
10 #include "webkit/appcache/appcache_storage.h" 10 #include "webkit/appcache/appcache_storage.h"
11 #include "webkit/appcache/mock_appcache_service.h" 11 #include "webkit/appcache/mock_appcache_service.h"
12 12
13 namespace appcache { 13 namespace appcache {
14 14
15 class AppCacheStorageTest : public testing::Test { 15 class AppCacheStorageTest : public testing::Test {
16 public: 16 public:
17 class MockStorageDelegate : public AppCacheStorage::Delegate { 17 class MockStorageDelegate : public AppCacheStorage::Delegate {
18 public: 18 public:
19 }; 19 };
20 20
21 class MockQuotaManagerProxy : public quota::QuotaManagerProxy { 21 class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
22 public: 22 public:
23 MockQuotaManagerProxy() 23 MockQuotaManagerProxy()
24 : QuotaManagerProxy(NULL, NULL), 24 : QuotaManagerProxy(NULL, NULL),
25 notify_storage_accessed_count_(0), 25 notify_storage_accessed_count_(0),
26 notify_storage_modified_count_(0), 26 notify_storage_modified_count_(0),
27 last_delta_(0) {} 27 last_delta_(0) {
28 }
28 29
29 virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id, 30 virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
30 const GURL& origin, 31 const GURL& origin,
31 quota::StorageType type) { 32 quota::StorageType type) OVERRIDE {
32 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id); 33 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
33 EXPECT_EQ(quota::kStorageTypeTemporary, type); 34 EXPECT_EQ(quota::kStorageTypeTemporary, type);
34 ++notify_storage_accessed_count_; 35 ++notify_storage_accessed_count_;
35 last_origin_ = origin; 36 last_origin_ = origin;
36 } 37 }
37 38
38 virtual void NotifyStorageModified(quota::QuotaClient::ID client_id, 39 virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
39 const GURL& origin, 40 const GURL& origin,
40 quota::StorageType type, 41 quota::StorageType type,
41 int64 delta) { 42 int64 delta) OVERRIDE {
42 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id); 43 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
43 EXPECT_EQ(quota::kStorageTypeTemporary, type); 44 EXPECT_EQ(quota::kStorageTypeTemporary, type);
44 ++notify_storage_modified_count_; 45 ++notify_storage_modified_count_;
45 last_origin_ = origin; 46 last_origin_ = origin;
46 last_delta_ = delta; 47 last_delta_ = delta;
47 } 48 }
48 49
49 // Not needed for our tests. 50 // Not needed for our tests.
50 virtual void RegisterClient(quota::QuotaClient* client) {} 51 virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {}
51 virtual void NotifyOriginInUse(const GURL& origin) {} 52 virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
52 virtual void NotifyOriginNoLongerInUse(const GURL& origin) {} 53 virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
53 54
54 int notify_storage_accessed_count_; 55 int notify_storage_accessed_count_;
55 int notify_storage_modified_count_; 56 int notify_storage_modified_count_;
56 GURL last_origin_; 57 GURL last_origin_;
57 int last_delta_; 58 int last_delta_;
59
60 protected:
61 virtual ~MockQuotaManagerProxy() {}
58 }; 62 };
59 }; 63 };
60 64
61 TEST_F(AppCacheStorageTest, AddRemoveCache) { 65 TEST_F(AppCacheStorageTest, AddRemoveCache) {
62 MockAppCacheService service; 66 MockAppCacheService service;
63 scoped_refptr<AppCache> cache(new AppCache(&service, 111)); 67 scoped_refptr<AppCache> cache(new AppCache(&service, 111));
64 68
65 EXPECT_EQ(cache.get(), 69 EXPECT_EQ(cache.get(),
66 service.storage()->working_set()->GetCache(111)); 70 service.storage()->working_set()->GetCache(111));
67 71
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 service.storage()->usage_map_.clear(); 187 service.storage()->usage_map_.clear();
184 service.storage()->usage_map_[kOrigin] = 5000; 188 service.storage()->usage_map_[kOrigin] = 5000;
185 service.storage()->ClearUsageMapAndNotify(); 189 service.storage()->ClearUsageMapAndNotify();
186 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count_); 190 EXPECT_EQ(4, mock_proxy->notify_storage_modified_count_);
187 EXPECT_EQ(-5000, mock_proxy->last_delta_); 191 EXPECT_EQ(-5000, mock_proxy->last_delta_);
188 EXPECT_EQ(kOrigin, mock_proxy->last_origin_); 192 EXPECT_EQ(kOrigin, mock_proxy->last_origin_);
189 EXPECT_TRUE(service.storage()->usage_map_.empty()); 193 EXPECT_TRUE(service.storage()->usage_map_.empty());
190 } 194 }
191 195
192 } // namespace appcache 196 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl_unittest.cc ('k') | webkit/appcache/appcache_update_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698