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

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

Issue 124183002: Implement delete methods for the various CannedBrowsingDataHelpers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h" 14 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h"
15 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" 15 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "content/public/browser/storage_partition.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace { 22 namespace {
22 typedef BrowsingDataHelperCallback<content::IndexedDBInfo> 23 typedef BrowsingDataHelperCallback<content::IndexedDBInfo>
23 TestCompletionCallback; 24 TestCompletionCallback;
24 25
25 typedef InProcessBrowserTest BrowsingDataIndexedDBHelperTest; 26 class BrowsingDataIndexedDBHelperTest : public InProcessBrowserTest {
27 public:
28 content::IndexedDBContext* IndexedDBContext() {
29 return content::BrowserContext::GetDefaultStoragePartition(
30 browser()->profile())->GetIndexedDBContext();
31 }
32 };
26 33
27 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { 34 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) {
28 const GURL origin1("http://host1:1/"); 35 const GURL origin1("http://host1:1/");
29 const GURL origin2("http://host2:1/"); 36 const GURL origin2("http://host2:1/");
30 const base::string16 description(base::ASCIIToUTF16("description")); 37 const base::string16 description(base::ASCIIToUTF16("description"));
31 38
32 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper( 39 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
33 new CannedBrowsingDataIndexedDBHelper()); 40 new CannedBrowsingDataIndexedDBHelper(IndexedDBContext()));
34 helper->AddIndexedDB(origin1, description); 41 helper->AddIndexedDB(origin1, description);
35 helper->AddIndexedDB(origin2, description); 42 helper->AddIndexedDB(origin2, description);
36 43
37 TestCompletionCallback callback; 44 TestCompletionCallback callback;
38 helper->StartFetching( 45 helper->StartFetching(
39 base::Bind(&TestCompletionCallback::callback, 46 base::Bind(&TestCompletionCallback::callback,
40 base::Unretained(&callback))); 47 base::Unretained(&callback)));
41 48
42 std::list<content::IndexedDBInfo> result = 49 std::list<content::IndexedDBInfo> result =
43 callback.result(); 50 callback.result();
44 51
45 ASSERT_EQ(2U, result.size()); 52 ASSERT_EQ(2U, result.size());
46 std::list<content::IndexedDBInfo>::iterator info = 53 std::list<content::IndexedDBInfo>::iterator info =
47 result.begin(); 54 result.begin();
48 EXPECT_EQ(origin1, info->origin_); 55 EXPECT_EQ(origin1, info->origin_);
49 info++; 56 info++;
50 EXPECT_EQ(origin2, info->origin_); 57 EXPECT_EQ(origin2, info->origin_);
51 } 58 }
52 59
53 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) { 60 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) {
54 const GURL origin("http://host1:1/"); 61 const GURL origin("http://host1:1/");
55 const base::string16 description(base::ASCIIToUTF16("description")); 62 const base::string16 description(base::ASCIIToUTF16("description"));
56 63
57 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper( 64 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
58 new CannedBrowsingDataIndexedDBHelper()); 65 new CannedBrowsingDataIndexedDBHelper(IndexedDBContext()));
59 helper->AddIndexedDB(origin, description); 66 helper->AddIndexedDB(origin, description);
60 helper->AddIndexedDB(origin, description); 67 helper->AddIndexedDB(origin, description);
61 68
62 TestCompletionCallback callback; 69 TestCompletionCallback callback;
63 helper->StartFetching( 70 helper->StartFetching(
64 base::Bind(&TestCompletionCallback::callback, 71 base::Bind(&TestCompletionCallback::callback,
65 base::Unretained(&callback))); 72 base::Unretained(&callback)));
66 73
67 std::list<content::IndexedDBInfo> result = 74 std::list<content::IndexedDBInfo> result =
68 callback.result(); 75 callback.result();
69 76
70 ASSERT_EQ(1U, result.size()); 77 ASSERT_EQ(1U, result.size());
71 EXPECT_EQ(origin, result.begin()->origin_); 78 EXPECT_EQ(origin, result.begin()->origin_);
72 } 79 }
73 } // namespace 80 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698