| 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/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
| 10 #include "chrome/browser/autocomplete/history_contents_provider.h" | 10 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } test_entries[] = { | 26 } test_entries[] = { |
| 27 {"http://www.google.com/1", "PAGEONE 1", "FOO some body text"}, | 27 {"http://www.google.com/1", "PAGEONE 1", "FOO some body text"}, |
| 28 {"http://www.google.com/2", "PAGEONE 2", "FOO some more blah blah"}, | 28 {"http://www.google.com/2", "PAGEONE 2", "FOO some more blah blah"}, |
| 29 {"http://www.google.com/3", "PAGETHREE 3", "BAR some hello world for you"}, | 29 {"http://www.google.com/3", "PAGETHREE 3", "BAR some hello world for you"}, |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class HistoryContentsProviderTest : public testing::Test, | 32 class HistoryContentsProviderTest : public testing::Test, |
| 33 public ACProviderListener { | 33 public ACProviderListener { |
| 34 public: | 34 public: |
| 35 HistoryContentsProviderTest() | 35 HistoryContentsProviderTest() |
| 36 : ui_thread_(ChromeThread::UI, &message_loop_), | 36 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 37 file_thread_(ChromeThread::FILE, &message_loop_) {} | 37 file_thread_(BrowserThread::FILE, &message_loop_) {} |
| 38 | 38 |
| 39 void RunQuery(const AutocompleteInput& input, | 39 void RunQuery(const AutocompleteInput& input, |
| 40 bool minimal_changes) { | 40 bool minimal_changes) { |
| 41 provider_->Start(input, minimal_changes); | 41 provider_->Start(input, minimal_changes); |
| 42 | 42 |
| 43 // When we're waiting for asynchronous messages, we have to spin the message | 43 // When we're waiting for asynchronous messages, we have to spin the message |
| 44 // loop. This will be exited in the OnProviderUpdate function when complete. | 44 // loop. This will be exited in the OnProviderUpdate function when complete. |
| 45 if (!input.synchronous_only()) | 45 if (!input.synchronous_only()) |
| 46 MessageLoop::current()->Run(); | 46 MessageLoop::current()->Run(); |
| 47 } | 47 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 profile_.reset(NULL); | 87 profile_.reset(NULL); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // ACProviderListener | 90 // ACProviderListener |
| 91 virtual void OnProviderUpdate(bool updated_matches) { | 91 virtual void OnProviderUpdate(bool updated_matches) { |
| 92 // When we quit, the test will get back control. | 92 // When we quit, the test will get back control. |
| 93 MessageLoop::current()->Quit(); | 93 MessageLoop::current()->Quit(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 MessageLoopForUI message_loop_; | 96 MessageLoopForUI message_loop_; |
| 97 ChromeThread ui_thread_; | 97 BrowserThread ui_thread_; |
| 98 ChromeThread file_thread_; | 98 BrowserThread file_thread_; |
| 99 | 99 |
| 100 std::wstring history_dir_; | 100 std::wstring history_dir_; |
| 101 | 101 |
| 102 scoped_ptr<TestingProfile> profile_; | 102 scoped_ptr<TestingProfile> profile_; |
| 103 scoped_refptr<HistoryContentsProvider> provider_; | 103 scoped_refptr<HistoryContentsProvider> provider_; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 TEST_F(HistoryContentsProviderTest, Body) { | 106 TEST_F(HistoryContentsProviderTest, Body) { |
| 107 AutocompleteInput input(L"FOO", std::wstring(), true, false, false); | 107 AutocompleteInput input(L"FOO", std::wstring(), true, false, false); |
| 108 RunQuery(input, false); | 108 RunQuery(input, false); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ASSERT_EQ(2U, m3.size()); | 185 ASSERT_EQ(2U, m3.size()); |
| 186 if (bookmark_url == m3[0].destination_url) { | 186 if (bookmark_url == m3[0].destination_url) { |
| 187 EXPECT_EQ("http://www.google.com/3", m3[1].destination_url.spec()); | 187 EXPECT_EQ("http://www.google.com/3", m3[1].destination_url.spec()); |
| 188 } else { | 188 } else { |
| 189 EXPECT_EQ(bookmark_url, m3[1].destination_url); | 189 EXPECT_EQ(bookmark_url, m3[1].destination_url); |
| 190 EXPECT_EQ("http://www.google.com/3", m3[0].destination_url.spec()); | 190 EXPECT_EQ("http://www.google.com/3", m3[0].destination_url.spec()); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace | 194 } // namespace |
| OLD | NEW |