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

Side by Side Diff: content/browser/indexed_db/indexed_db_quota_client_unittest.cc

Issue 1757693002: Reduce use of DatabaseIdentifier in Indexed DB entry points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert change for ZIP file naming Created 4 years, 9 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
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/test/test_simple_task_runner.h" 14 #include "base/test/test_simple_task_runner.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "content/browser/browser_thread_impl.h" 16 #include "content/browser/browser_thread_impl.h"
17 #include "content/browser/indexed_db/indexed_db_context_impl.h" 17 #include "content/browser/indexed_db/indexed_db_context_impl.h"
18 #include "content/browser/indexed_db/indexed_db_quota_client.h" 18 #include "content/browser/indexed_db/indexed_db_quota_client.h"
19 #include "content/browser/quota/mock_quota_manager.h" 19 #include "content/browser/quota/mock_quota_manager.h"
20 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
21 #include "content/public/test/test_browser_context.h" 21 #include "content/public/test/test_browser_context.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "storage/common/database/database_identifier.h"
24 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
25 24
26 // Declared to shorten the line lengths. 25 // Declared to shorten the line lengths.
27 static const storage::StorageType kTemp = storage::kStorageTypeTemporary; 26 static const storage::StorageType kTemp = storage::kStorageTypeTemporary;
28 static const storage::StorageType kPerm = storage::kStorageTypePersistent; 27 static const storage::StorageType kPerm = storage::kStorageTypePersistent;
29 28
30 namespace content { 29 namespace content {
31 30
32 // Base class for our test fixtures. 31 // Base class for our test fixtures.
33 class IndexedDBQuotaClientTest : public testing::Test { 32 class IndexedDBQuotaClientTest : public testing::Test {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 131 }
133 132
134 IndexedDBContextImpl* idb_context() { return idb_context_.get(); } 133 IndexedDBContextImpl* idb_context() { return idb_context_.get(); }
135 134
136 void SetFileSizeTo(const base::FilePath& path, int size) { 135 void SetFileSizeTo(const base::FilePath& path, int size) {
137 std::string junk(size, 'a'); 136 std::string junk(size, 'a');
138 ASSERT_EQ(size, base::WriteFile(path, junk.c_str(), size)); 137 ASSERT_EQ(size, base::WriteFile(path, junk.c_str(), size));
139 } 138 }
140 139
141 void AddFakeIndexedDB(const GURL& origin, int size) { 140 void AddFakeIndexedDB(const GURL& origin, int size) {
142 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting( 141 base::FilePath file_path_origin =
143 storage::GetIdentifierFromOrigin(origin)); 142 idb_context()->GetFilePathForTesting(origin);
144 if (!base::CreateDirectory(file_path_origin)) { 143 if (!base::CreateDirectory(file_path_origin)) {
145 LOG(ERROR) << "failed to base::CreateDirectory " 144 LOG(ERROR) << "failed to base::CreateDirectory "
146 << file_path_origin.value(); 145 << file_path_origin.value();
147 } 146 }
148 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 147 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
149 SetFileSizeTo(file_path_origin, size); 148 SetFileSizeTo(file_path_origin, size);
150 idb_context()->ResetCaches(); 149 idb_context()->ResetCaches();
151 } 150 }
152 151
153 private: 152 private:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 236 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
238 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 237 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
239 238
240 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 239 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
241 EXPECT_EQ(storage::kQuotaStatusOk, delete_status); 240 EXPECT_EQ(storage::kQuotaStatusOk, delete_status);
242 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 241 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
243 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 242 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
244 } 243 }
245 244
246 } // namespace content 245 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698