Update V8 to version 4.7.21.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_cache_storage_helper_browsertest.cc
blobd5634767f5ffeadf59076665a649cc12e10f14bc
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.
5 #include <string>
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "content/public/browser/storage_partition.h"
20 #include "testing/gtest/include/gtest/gtest.h"
22 namespace {
23 typedef BrowsingDataHelperCallback<content::CacheStorageUsageInfo>
24 TestCompletionCallback;
26 class BrowsingDataCacheStorageHelperTest : public InProcessBrowserTest {
27 public:
28 content::CacheStorageContext* CacheStorageContext() {
29 return content::BrowserContext::GetDefaultStoragePartition(
30 browser()->profile())
31 ->GetCacheStorageContext();
35 IN_PROC_BROWSER_TEST_F(BrowsingDataCacheStorageHelperTest,
36 CannedAddCacheStorage) {
37 const GURL origin1("http://host1:1/");
38 const GURL origin2("http://host2:1/");
40 scoped_refptr<CannedBrowsingDataCacheStorageHelper> helper(
41 new CannedBrowsingDataCacheStorageHelper(CacheStorageContext()));
42 helper->AddCacheStorage(origin1);
43 helper->AddCacheStorage(origin2);
45 TestCompletionCallback callback;
46 helper->StartFetching(base::Bind(&TestCompletionCallback::callback,
47 base::Unretained(&callback)));
49 std::list<content::CacheStorageUsageInfo> result = callback.result();
51 ASSERT_EQ(2U, result.size());
52 std::list<content::CacheStorageUsageInfo>::iterator info = result.begin();
53 EXPECT_EQ(origin1, info->origin);
54 info++;
55 EXPECT_EQ(origin2, info->origin);
58 IN_PROC_BROWSER_TEST_F(BrowsingDataCacheStorageHelperTest, CannedUnique) {
59 const GURL origin("http://host1:1/");
61 scoped_refptr<CannedBrowsingDataCacheStorageHelper> helper(
62 new CannedBrowsingDataCacheStorageHelper(CacheStorageContext()));
63 helper->AddCacheStorage(origin);
64 helper->AddCacheStorage(origin);
66 TestCompletionCallback callback;
67 helper->StartFetching(base::Bind(&TestCompletionCallback::callback,
68 base::Unretained(&callback)));
70 std::list<content::CacheStorageUsageInfo> result = callback.result();
72 ASSERT_EQ(1U, result.size());
73 EXPECT_EQ(origin, result.begin()->origin);
75 } // namespace