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

Side by Side Diff: webkit/dom_storage/dom_storage_context_unittest.cc

Issue 10413072: Teaching BrowsingDataRemover how to delete application data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: How's this direction? Created 8 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 MessageLoop::current()->RunAllPending(); 51 MessageLoop::current()->RunAllPending();
52 } 52 }
53 53
54 void VerifySingleOriginRemains(const GURL& origin) { 54 void VerifySingleOriginRemains(const GURL& origin) {
55 // Use a new instance to examine the contexts of temp_dir_. 55 // Use a new instance to examine the contexts of temp_dir_.
56 scoped_refptr<DomStorageContext> context = 56 scoped_refptr<DomStorageContext> context =
57 new DomStorageContext(temp_dir_.path(), FilePath(), NULL, NULL); 57 new DomStorageContext(temp_dir_.path(), FilePath(), NULL, NULL);
58 std::vector<DomStorageContext::UsageInfo> infos; 58 std::vector<DomStorageContext::UsageInfo> infos;
59 context->GetUsageInfo(&infos, kDontIncludeFileInfo); 59 context->GetUsageInfo(&infos, kDontIncludeFileInfo);
60 EXPECT_EQ(1u, infos.size()); 60 EXPECT_EQ(1u, infos.size());
61 EXPECT_EQ(origin, infos[0].origin); 61 if (infos.size() > 0)
Bernhard Bauer 2012/05/31 15:57:31 You could ASSERT instead.
Mike West 2012/06/01 13:35:17 Done.
62 EXPECT_EQ(origin, infos[0].origin);
62 } 63 }
63 64
64 protected: 65 protected:
65 ScopedTempDir temp_dir_; 66 ScopedTempDir temp_dir_;
66 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; 67 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_;
67 scoped_refptr<MockDomStorageTaskRunner> task_runner_; 68 scoped_refptr<MockDomStorageTaskRunner> task_runner_;
68 scoped_refptr<DomStorageContext> context_; 69 scoped_refptr<DomStorageContext> context_;
69 DISALLOW_COPY_AND_ASSIGN(DomStorageContextTest); 70 DISALLOW_COPY_AND_ASSIGN(DomStorageContextTest);
70 }; 71 };
71 72
72 TEST_F(DomStorageContextTest, Basics) { 73 TEST_F(DomStorageContextTest, Basics) {
73 // This test doesn't do much, checks that the constructor 74 // This test doesn't do much, checks that the constructor
74 // initializes members properly and that invoking methods 75 // initializes members properly and that invoking methods
75 // on a newly created object w/o any data on disk do no harm. 76 // on a newly created object w/o any data on disk do no harm.
76 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory()); 77 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory());
77 EXPECT_EQ(FilePath(), context_->sessionstorage_directory()); 78 EXPECT_EQ(FilePath(), context_->sessionstorage_directory());
78 EXPECT_EQ(storage_policy_.get(), context_->special_storage_policy_.get()); 79 EXPECT_EQ(storage_policy_.get(), context_->special_storage_policy_.get());
79 context_->PurgeMemory(); 80 context_->PurgeMemory();
80 context_->DeleteOrigin(GURL("http://chromium.org/")); 81 context_->DeleteOrigin(GURL("http://chromium.org/"));
81 context_->DeleteDataModifiedSince(base::Time::Now());
82 const int kFirstSessionStorageNamespaceId = 1; 82 const int kFirstSessionStorageNamespaceId = 1;
83 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId)); 83 EXPECT_TRUE(context_->GetStorageNamespace(kLocalStorageNamespaceId));
84 EXPECT_FALSE(context_->GetStorageNamespace(kFirstSessionStorageNamespaceId)); 84 EXPECT_FALSE(context_->GetStorageNamespace(kFirstSessionStorageNamespaceId));
85 EXPECT_EQ(kFirstSessionStorageNamespaceId, context_->AllocateSessionId()); 85 EXPECT_EQ(kFirstSessionStorageNamespaceId, context_->AllocateSessionId());
86 std::vector<DomStorageContext::UsageInfo> infos; 86 std::vector<DomStorageContext::UsageInfo> infos;
87 context_->GetUsageInfo(&infos, kDontIncludeFileInfo); 87 context_->GetUsageInfo(&infos, kDontIncludeFileInfo);
88 EXPECT_TRUE(infos.empty()); 88 EXPECT_TRUE(infos.empty());
89 context_->Shutdown(); 89 context_->Shutdown();
90 } 90 }
91 91
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 context_->SetClearLocalState(true); 173 context_->SetClearLocalState(true);
174 context_->SaveSessionState(); // Should override clear behavior. 174 context_->SaveSessionState(); // Should override clear behavior.
175 context_->Shutdown(); 175 context_->Shutdown();
176 context_ = NULL; 176 context_ = NULL;
177 MessageLoop::current()->RunAllPending(); 177 MessageLoop::current()->RunAllPending();
178 178
179 VerifySingleOriginRemains(kSessionOnlyOrigin); 179 VerifySingleOriginRemains(kSessionOnlyOrigin);
180 } 180 }
181 181
182 } // namespace dom_storage 182 } // namespace dom_storage
OLDNEW
« content/public/browser/dom_storage_context.h ('K') | « webkit/dom_storage/dom_storage_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698