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

Side by Side 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: nits fix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/fileapi/file_system_usage_tracker.h"
6
7 #include "base/basictypes.h"
8 #include "base/file_util.h"
9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h"
11 #include "base/scoped_callback_factory.h"
12 #include "googleurl/src/gurl.h"
13 #include "base/scoped_temp_dir.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/fileapi/file_system_path_manager.h"
16 #include "webkit/fileapi/file_system_types.h"
17
18 using namespace fileapi;
19
20 class FileSystemUsageTrackerTest : public testing::Test {
21 public:
22 FileSystemUsageTrackerTest()
23 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
24 }
25
26 void SetUp() {
27 data_dir_.reset(new ScopedTempDir);
28 ASSERT_TRUE(data_dir_->CreateUniqueTempDir());
29 }
30
31 protected:
32 FileSystemUsageTracker* NewUsageTracker(bool is_incognito) {
33 return new FileSystemUsageTracker(
34 base::MessageLoopProxy::CreateForCurrentThread(),
35 data_dir_->path(), is_incognito);
36 }
37
38 int64 GetOriginUsage(FileSystemUsageTracker* tracker,
39 const GURL& origin_url,
40 fileapi::FileSystemType type) {
41 tracker->GetOriginUsage(origin_url, type,
42 callback_factory_.NewCallback(
43 &FileSystemUsageTrackerTest::OnGetUsage));
44 MessageLoop::current()->RunAllPending();
45 return usage_;
46 }
47
48 private:
49 void OnGetUsage(int64 usage) {
50 usage_ = usage;
51 }
52
53 scoped_ptr<ScopedTempDir> data_dir_;
Paweł Hajdan Jr. 2011/02/08 11:25:50 nit: Why not stack-allocated?
kinuko 2011/02/08 13:36:12 Done.
54 base::ScopedCallbackFactory<FileSystemUsageTrackerTest> callback_factory_;
55 int64 usage_;
56
57 DISALLOW_COPY_AND_ASSIGN(FileSystemUsageTrackerTest);
58 };
59
60 // TODO(dmikurube): change this test to a meaningful one once we add the real
61 // code in FileSystemUsageTracker.
62 TEST_F(FileSystemUsageTrackerTest, DummyTest) {
63 scoped_ptr<FileSystemUsageTracker> tracker(NewUsageTracker(false));
64 ASSERT_EQ(0, GetOriginUsage(tracker.get(),
65 GURL("http://www.dummy.org/"),
66 fileapi::kFileSystemTypeTemporary));
67 }
OLDNEW
« 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