| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/history_url_provider.h" | 10 #include "chrome/browser/autocomplete/history_url_provider.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // URLs for testing ctrl-enter behavior. | 89 // URLs for testing ctrl-enter behavior. |
| 90 {"http://binky/", "Intranet binky", 2, 2}, | 90 {"http://binky/", "Intranet binky", 2, 2}, |
| 91 {"http://winky/", "Intranet winky", 2, 2}, | 91 {"http://winky/", "Intranet winky", 2, 2}, |
| 92 {"http://www.winky.com/", "Internet winky", 5, 0}, | 92 {"http://www.winky.com/", "Internet winky", 5, 0}, |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 class HistoryURLProviderTest : public testing::Test, | 95 class HistoryURLProviderTest : public testing::Test, |
| 96 public ACProviderListener { | 96 public ACProviderListener { |
| 97 public: | 97 public: |
| 98 HistoryURLProviderTest() | 98 HistoryURLProviderTest() |
| 99 : ui_thread_(ChromeThread::UI, &message_loop_), | 99 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 100 file_thread_(ChromeThread::FILE, &message_loop_) {} | 100 file_thread_(BrowserThread::FILE, &message_loop_) {} |
| 101 | 101 |
| 102 // ACProviderListener | 102 // ACProviderListener |
| 103 virtual void OnProviderUpdate(bool updated_matches); | 103 virtual void OnProviderUpdate(bool updated_matches); |
| 104 | 104 |
| 105 protected: | 105 protected: |
| 106 // testing::Test | 106 // testing::Test |
| 107 virtual void SetUp() { | 107 virtual void SetUp() { |
| 108 SetUpImpl(false); | 108 SetUpImpl(false); |
| 109 } | 109 } |
| 110 virtual void TearDown(); | 110 virtual void TearDown(); |
| 111 | 111 |
| 112 // Does the real setup. | 112 // Does the real setup. |
| 113 void SetUpImpl(bool no_db); | 113 void SetUpImpl(bool no_db); |
| 114 | 114 |
| 115 // Fills test data into the history system. | 115 // Fills test data into the history system. |
| 116 void FillData(); | 116 void FillData(); |
| 117 | 117 |
| 118 // Runs an autocomplete query on |text| and checks to see that the returned | 118 // Runs an autocomplete query on |text| and checks to see that the returned |
| 119 // results' destination URLs match those provided. | 119 // results' destination URLs match those provided. |
| 120 void RunTest(const std::wstring text, | 120 void RunTest(const std::wstring text, |
| 121 const std::wstring& desired_tld, | 121 const std::wstring& desired_tld, |
| 122 bool prevent_inline_autocomplete, | 122 bool prevent_inline_autocomplete, |
| 123 const std::string* expected_urls, | 123 const std::string* expected_urls, |
| 124 size_t num_results); | 124 size_t num_results); |
| 125 | 125 |
| 126 void RunAdjustOffsetTest(const std::wstring text, size_t expected_offset); | 126 void RunAdjustOffsetTest(const std::wstring text, size_t expected_offset); |
| 127 | 127 |
| 128 MessageLoopForUI message_loop_; | 128 MessageLoopForUI message_loop_; |
| 129 ChromeThread ui_thread_; | 129 BrowserThread ui_thread_; |
| 130 ChromeThread file_thread_; | 130 BrowserThread file_thread_; |
| 131 ACMatches matches_; | 131 ACMatches matches_; |
| 132 scoped_ptr<TestingProfile> profile_; | 132 scoped_ptr<TestingProfile> profile_; |
| 133 HistoryService* history_service_; | 133 HistoryService* history_service_; |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 scoped_refptr<HistoryURLProvider> autocomplete_; | 136 scoped_refptr<HistoryURLProvider> autocomplete_; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 class HistoryURLProviderTestNoDB : public HistoryURLProviderTest { | 139 class HistoryURLProviderTestNoDB : public HistoryURLProviderTest { |
| 140 protected: | 140 protected: |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 std::string navigation_1[] = {"http://test.com/"}; | 449 std::string navigation_1[] = {"http://test.com/"}; |
| 450 RunTest(L"test.com", std::wstring(), false, navigation_1, | 450 RunTest(L"test.com", std::wstring(), false, navigation_1, |
| 451 arraysize(navigation_1)); | 451 arraysize(navigation_1)); |
| 452 | 452 |
| 453 std::string navigation_2[] = {"http://slash/"}; | 453 std::string navigation_2[] = {"http://slash/"}; |
| 454 RunTest(L"slash", std::wstring(), false, navigation_2, | 454 RunTest(L"slash", std::wstring(), false, navigation_2, |
| 455 arraysize(navigation_2)); | 455 arraysize(navigation_2)); |
| 456 | 456 |
| 457 RunTest(L"this is a query", std::wstring(), false, NULL, 0); | 457 RunTest(L"this is a query", std::wstring(), false, NULL, 0); |
| 458 } | 458 } |
| OLD | NEW |