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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webdatabase/QuotaTracker.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp
diff --git a/third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp b/third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..804c1df8e3edea1bf0f9212d10669a4ea94bd7a5
--- /dev/null
+++ b/third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/webdatabase/QuotaTracker.h"
+
+#include "platform/weborigin/SecurityOrigin.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/RefPtr.h"
+
+namespace blink {
+namespace {
+
+TEST(QuotaTrackerTest, UpdateAndGetSizeAndSpaceAvailable)
+{
+ QuotaTracker& tracker = QuotaTracker::instance();
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("file:///a/b/c");
+
+ const unsigned long long spaceAvailable = 12345678ULL;
+ tracker.updateSpaceAvailableToOrigin(origin.get(), spaceAvailable);
+
+ const String databaseName = "db";
+ const unsigned long long databaseSize = 1234ULL;
+ tracker.updateDatabaseSize(origin.get(), databaseName, databaseSize);
+
+ unsigned long long used = 0;
+ unsigned long long available = 0;
+ tracker.getDatabaseSizeAndSpaceAvailableToOrigin(origin.get(), databaseName, &used, &available);
+
+ EXPECT_EQ(used, databaseSize);
+ EXPECT_EQ(available, spaceAvailable);
+}
+
+TEST(QuotaTrackerTest, LocalAccessBlocked)
+{
+ QuotaTracker& tracker = QuotaTracker::instance();
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromString("file:///a/b/c");
+
+ const unsigned long long spaceAvailable = 12345678ULL;
+ tracker.updateSpaceAvailableToOrigin(origin.get(), spaceAvailable);
+
+ const String databaseName = "db";
+ const unsigned long long databaseSize = 1234ULL;
+ tracker.updateDatabaseSize(origin.get(), databaseName, databaseSize);
+
+ // QuotaTracker should not care about policy, just identity.
+ origin->blockLocalAccessFromLocalOrigin();
+
+ unsigned long long used = 0;
+ unsigned long long available = 0;
+ tracker.getDatabaseSizeAndSpaceAvailableToOrigin(origin.get(), databaseName, &used, &available);
+
+ EXPECT_EQ(used, databaseSize);
+ EXPECT_EQ(available, spaceAvailable);
+}
+
+} // namespace
+} // namespace blink
« 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