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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp

Issue 1914763002: QuotaTracker: Use 'raw' string as key for origin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests Created 4 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
« no previous file with comments | « third_party/WebKit/Source/modules/webdatabase/QuotaTracker.cpp ('k') | no next file » | 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 2016 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 "modules/webdatabase/QuotaTracker.h"
6
7 #include "platform/weborigin/SecurityOrigin.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "wtf/RefPtr.h"
10
11 namespace blink {
12 namespace {
13
14 TEST(QuotaTrackerTest, UpdateAndGetSizeAndSpaceAvailable)
15 {
16 QuotaTracker& tracker = QuotaTracker::instance();
17 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("file:///a/ b/c");
18
19 const unsigned long long spaceAvailable = 12345678ULL;
20 tracker.updateSpaceAvailableToOrigin(origin.get(), spaceAvailable);
21
22 const String databaseName = "db";
23 const unsigned long long databaseSize = 1234ULL;
24 tracker.updateDatabaseSize(origin.get(), databaseName, databaseSize);
25
26 unsigned long long used = 0;
27 unsigned long long available = 0;
28 tracker.getDatabaseSizeAndSpaceAvailableToOrigin(origin.get(), databaseName, &used, &available);
29
30 EXPECT_EQ(used, databaseSize);
31 EXPECT_EQ(available, spaceAvailable);
32 }
33
34 TEST(QuotaTrackerTest, LocalAccessBlocked)
35 {
36 QuotaTracker& tracker = QuotaTracker::instance();
37 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("file:///a/ b/c");
38
39 const unsigned long long spaceAvailable = 12345678ULL;
40 tracker.updateSpaceAvailableToOrigin(origin.get(), spaceAvailable);
41
42 const String databaseName = "db";
43 const unsigned long long databaseSize = 1234ULL;
44 tracker.updateDatabaseSize(origin.get(), databaseName, databaseSize);
45
46 // QuotaTracker should not care about policy, just identity.
47 origin->blockLocalAccessFromLocalOrigin();
48
49 unsigned long long used = 0;
50 unsigned long long available = 0;
51 tracker.getDatabaseSizeAndSpaceAvailableToOrigin(origin.get(), databaseName, &used, &available);
52
53 EXPECT_EQ(used, databaseSize);
54 EXPECT_EQ(available, spaceAvailable);
55 }
56
57 } // namespace
58 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webdatabase/QuotaTracker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698