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

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

Issue 7601006: GTTF: Use a fresh TestingBrowserProcess for each test, part #5 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/callback.h" 8 #include "base/callback.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/browsing_data_helper_browsertest.h" 13 #include "chrome/browser/browsing_data_helper_browsertest.h"
14 #include "chrome/browser/browsing_data_indexed_db_helper.h" 14 #include "chrome/browser/browsing_data_indexed_db_helper.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h"
15 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/testing_profile.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace { 20 namespace {
20 typedef BrowsingDataHelperCallback<BrowsingDataIndexedDBHelper::IndexedDBInfo> 21 typedef BrowsingDataHelperCallback<BrowsingDataIndexedDBHelper::IndexedDBInfo>
21 TestCompletionCallback; 22 TestCompletionCallback;
22 23
23 class BrowsingDataIndexedDBHelperTest : public InProcessBrowserTest { 24 class BrowsingDataIndexedDBHelperTest : public InProcessBrowserTest {
24 protected:
25 TestingProfile testing_profile_;
26 }; 25 };
27 26
28 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { 27 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) {
29 const GURL origin1("http://host1:1/"); 28 const GURL origin1("http://host1:1/");
30 const GURL origin2("http://host2:1/"); 29 const GURL origin2("http://host2:1/");
31 const string16 description(ASCIIToUTF16("description")); 30 const string16 description(ASCIIToUTF16("description"));
32 const FilePath::CharType file1[] = 31 const FilePath::CharType file1[] =
33 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb"); 32 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb");
34 const FilePath::CharType file2[] = 33 const FilePath::CharType file2[] =
35 FILE_PATH_LITERAL("http_host2_1.indexeddb.leveldb"); 34 FILE_PATH_LITERAL("http_host2_1.indexeddb.leveldb");
36 35
37 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper( 36 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
38 new CannedBrowsingDataIndexedDBHelper(&testing_profile_)); 37 new CannedBrowsingDataIndexedDBHelper(browser()->profile()));
39 helper->AddIndexedDB(origin1, description); 38 helper->AddIndexedDB(origin1, description);
40 helper->AddIndexedDB(origin2, description); 39 helper->AddIndexedDB(origin2, description);
41 40
42 TestCompletionCallback callback; 41 TestCompletionCallback callback;
43 helper->StartFetching( 42 helper->StartFetching(
44 NewCallback(&callback, &TestCompletionCallback::callback)); 43 NewCallback(&callback, &TestCompletionCallback::callback));
45 44
46 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = 45 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result =
47 callback.result(); 46 callback.result();
48 47
49 ASSERT_EQ(2U, result.size()); 48 ASSERT_EQ(2U, result.size());
50 EXPECT_EQ(FilePath(file1).value(), result[0].file_path.BaseName().value()); 49 EXPECT_EQ(FilePath(file1).value(), result[0].file_path.BaseName().value());
51 EXPECT_EQ(FilePath(file2).value(), result[1].file_path.BaseName().value()); 50 EXPECT_EQ(FilePath(file2).value(), result[1].file_path.BaseName().value());
52 } 51 }
53 52
54 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) { 53 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedUnique) {
55 const GURL origin("http://host1:1/"); 54 const GURL origin("http://host1:1/");
56 const string16 description(ASCIIToUTF16("description")); 55 const string16 description(ASCIIToUTF16("description"));
57 const FilePath::CharType file[] = 56 const FilePath::CharType file[] =
58 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb"); 57 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb");
59 58
60 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper( 59 scoped_refptr<CannedBrowsingDataIndexedDBHelper> helper(
61 new CannedBrowsingDataIndexedDBHelper(&testing_profile_)); 60 new CannedBrowsingDataIndexedDBHelper(browser()->profile()));
62 helper->AddIndexedDB(origin, description); 61 helper->AddIndexedDB(origin, description);
63 helper->AddIndexedDB(origin, description); 62 helper->AddIndexedDB(origin, description);
64 63
65 TestCompletionCallback callback; 64 TestCompletionCallback callback;
66 helper->StartFetching( 65 helper->StartFetching(
67 NewCallback(&callback, &TestCompletionCallback::callback)); 66 NewCallback(&callback, &TestCompletionCallback::callback));
68 67
69 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = 68 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result =
70 callback.result(); 69 callback.result();
71 70
72 ASSERT_EQ(1U, result.size()); 71 ASSERT_EQ(1U, result.size());
73 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); 72 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
74 } 73 }
75 } // namespace 74 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698