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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_cache_storage_helper_unittest.cc

Issue 1297093002: Cache Storage API: Hook up to chrome://settings/cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy/paste in OSX, sigh Created 5 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "base/thread_task_runner_handle.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/storage_partition.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace {
16
17 class CannedBrowsingDataCacheStorageHelperTest : public testing::Test {
18 public:
19 content::CacheStorageContext* CacheStorageContext() {
20 return content::BrowserContext::GetDefaultStoragePartition(&profile_)
21 ->GetCacheStorageContext();
22 }
23
24 private:
25 content::TestBrowserThreadBundle thread_bundle_;
26 TestingProfile profile_;
27 };
28
29 TEST_F(CannedBrowsingDataCacheStorageHelperTest, Empty) {
30 const GURL origin("http://host1:1/");
31
32 scoped_refptr<CannedBrowsingDataCacheStorageHelper> helper(
33 new CannedBrowsingDataCacheStorageHelper(CacheStorageContext()));
34
35 ASSERT_TRUE(helper->empty());
36 helper->AddCacheStorage(origin);
37 ASSERT_FALSE(helper->empty());
38 helper->Reset();
39 ASSERT_TRUE(helper->empty());
40 }
41
42 TEST_F(CannedBrowsingDataCacheStorageHelperTest, Delete) {
43 const GURL origin1("http://host1:9000");
44 const GURL origin2("http://example.com");
45
46 scoped_refptr<CannedBrowsingDataCacheStorageHelper> helper(
47 new CannedBrowsingDataCacheStorageHelper(CacheStorageContext()));
48
49 EXPECT_TRUE(helper->empty());
50 helper->AddCacheStorage(origin1);
51 helper->AddCacheStorage(origin2);
52 helper->AddCacheStorage(origin2);
53 EXPECT_EQ(2u, helper->GetCacheStorageCount());
54 helper->DeleteCacheStorage(origin2);
55 EXPECT_EQ(1u, helper->GetCacheStorageCount());
56 }
57
58 TEST_F(CannedBrowsingDataCacheStorageHelperTest, IgnoreExtensionsAndDevTools) {
59 const GURL origin1("chrome-extension://abcdefghijklmnopqrstuvwxyz/");
60 const GURL origin2("chrome-devtools://abcdefghijklmnopqrstuvwxyz/");
61
62 scoped_refptr<CannedBrowsingDataCacheStorageHelper> helper(
63 new CannedBrowsingDataCacheStorageHelper(CacheStorageContext()));
64
65 ASSERT_TRUE(helper->empty());
66 helper->AddCacheStorage(origin1);
67 ASSERT_TRUE(helper->empty());
68 helper->AddCacheStorage(origin2);
69 ASSERT_TRUE(helper->empty());
70 }
71
72 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698