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

Unified Diff: webkit/fileapi/file_system_usage_tracker_unittest.cc

Issue 6426001: Add 1st cut of FileSystemUsageTracker that tracks the usage changes in FileSystem API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix for win Created 9 years, 10 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 | « webkit/fileapi/file_system_usage_tracker.cc ('k') | webkit/fileapi/sandboxed_file_system_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/file_system_usage_tracker_unittest.cc
diff --git a/webkit/fileapi/file_system_usage_tracker_unittest.cc b/webkit/fileapi/file_system_usage_tracker_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0d8a33c3f9c5b2c4659886e2f6a84f5c1ed6389a
--- /dev/null
+++ b/webkit/fileapi/file_system_usage_tracker_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2011 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 "webkit/fileapi/file_system_usage_tracker.h"
+
+#include "base/basictypes.h"
+#include "base/file_util.h"
+#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
+#include "base/scoped_callback_factory.h"
+#include "googleurl/src/gurl.h"
+#include "base/scoped_temp_dir.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/fileapi/file_system_path_manager.h"
+#include "webkit/fileapi/file_system_types.h"
+
+using namespace fileapi;
+
+class FileSystemUsageTrackerTest : public testing::Test {
+ public:
+ FileSystemUsageTrackerTest()
+ : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ }
+
+ void SetUp() {
+ ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
+ }
+
+ protected:
+ FileSystemUsageTracker* NewUsageTracker(bool is_incognito) {
+ return new FileSystemUsageTracker(
+ base::MessageLoopProxy::CreateForCurrentThread(),
+ data_dir_.path(), is_incognito);
+ }
+
+ int64 GetOriginUsage(FileSystemUsageTracker* tracker,
+ const GURL& origin_url,
+ fileapi::FileSystemType type) {
+ tracker->GetOriginUsage(origin_url, type,
+ callback_factory_.NewCallback(
+ &FileSystemUsageTrackerTest::OnGetUsage));
+ MessageLoop::current()->RunAllPending();
+ return usage_;
+ }
+
+ private:
+ void OnGetUsage(int64 usage) {
+ usage_ = usage;
+ }
+
+ ScopedTempDir data_dir_;
+ base::ScopedCallbackFactory<FileSystemUsageTrackerTest> callback_factory_;
+ int64 usage_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileSystemUsageTrackerTest);
+};
+
+// TODO(dmikurube): change this test to a meaningful one once we add
+// the real code in the FileSystemUsageTracker.
+TEST_F(FileSystemUsageTrackerTest, DummyTest) {
+ scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
+ ASSERT_EQ(0, GetOriginUsage(tracker.get(),
+ GURL("http://www.dummy.org/"),
+ fileapi::kFileSystemTypeTemporary));
+}
« no previous file with comments | « webkit/fileapi/file_system_usage_tracker.cc ('k') | webkit/fileapi/sandboxed_file_system_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698