| OLD | NEW |
| 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/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
| 16 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
| 17 #include "content/browser/mock_resource_context.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 { |
| 25 public: |
| 26 virtual void SetUpOnMainThread() { |
| 27 // Make sure TestURLRequestContext gets initliazed early enough (it needs to |
| 28 // be constructed in the UI thread). Normally Profile's URLRequestContext is |
| 29 // initialized early enough, but the same is not true for the |
| 30 // TestingProfile. |
| 31 content::MockResourceContext::GetInstance(); |
| 32 } |
| 24 protected: | 33 protected: |
| 25 TestingProfile testing_profile_; | 34 TestingProfile testing_profile_; |
| 26 }; | 35 }; |
| 27 | 36 |
| 28 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { | 37 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest, CannedAddIndexedDB) { |
| 29 const GURL origin1("http://host1:1/"); | 38 const GURL origin1("http://host1:1/"); |
| 30 const GURL origin2("http://host2:1/"); | 39 const GURL origin2("http://host2:1/"); |
| 31 const string16 description(ASCIIToUTF16("description")); | 40 const string16 description(ASCIIToUTF16("description")); |
| 32 const FilePath::CharType file1[] = | 41 const FilePath::CharType file1[] = |
| 33 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb"); | 42 FILE_PATH_LITERAL("http_host1_1.indexeddb.leveldb"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 helper->StartFetching( | 75 helper->StartFetching( |
| 67 NewCallback(&callback, &TestCompletionCallback::callback)); | 76 NewCallback(&callback, &TestCompletionCallback::callback)); |
| 68 | 77 |
| 69 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = | 78 std::vector<BrowsingDataIndexedDBHelper::IndexedDBInfo> result = |
| 70 callback.result(); | 79 callback.result(); |
| 71 | 80 |
| 72 ASSERT_EQ(1U, result.size()); | 81 ASSERT_EQ(1U, result.size()); |
| 73 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); | 82 EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value()); |
| 74 } | 83 } |
| 75 } // namespace | 84 } // namespace |
| OLD | NEW |