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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider_unittest.cc

Issue 6478005: GTTF: Use a fresh TestingBrowserProcess for each test, part #1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base class Created 9 years, 10 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) 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/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
11 #include "chrome/browser/autocomplete/history_url_provider.h" 11 #include "chrome/browser/autocomplete/history_url_provider.h"
12 #include "chrome/browser/browser_thread.h" 12 #include "chrome/browser/browser_thread.h"
13 #include "chrome/browser/history/history.h" 13 #include "chrome/browser/history/history.h"
14 #include "chrome/test/testing_browser_process.h"
14 #include "chrome/test/testing_profile.h" 15 #include "chrome/test/testing_profile.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using base::Time; 18 using base::Time;
18 using base::TimeDelta; 19 using base::TimeDelta;
19 20
20 struct TestURLInfo { 21 struct TestURLInfo {
21 std::string url; 22 std::string url;
22 std::string title; 23 std::string title;
23 int visit_count; 24 int visit_count;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 {"http://www.\xEA\xB5\x90\xEC\x9C\xA1.kr/", "Korean", 2, 2}, 84 {"http://www.\xEA\xB5\x90\xEC\x9C\xA1.kr/", "Korean", 2, 2},
84 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2}, 85 {"http://spaces.com/path%20with%20spaces/foo.html", "Spaces", 2, 2},
85 {"http://ms/c++%20style%20guide", "Style guide", 2, 2}, 86 {"http://ms/c++%20style%20guide", "Style guide", 2, 2},
86 87
87 // URLs for testing ctrl-enter behavior. 88 // URLs for testing ctrl-enter behavior.
88 {"http://binky/", "Intranet binky", 2, 2}, 89 {"http://binky/", "Intranet binky", 2, 2},
89 {"http://winky/", "Intranet winky", 2, 2}, 90 {"http://winky/", "Intranet winky", 2, 2},
90 {"http://www.winky.com/", "Internet winky", 5, 0}, 91 {"http://www.winky.com/", "Internet winky", 5, 0},
91 }; 92 };
92 93
93 class HistoryURLProviderTest : public testing::Test, 94 class HistoryURLProviderTest : public testing::Test,
sky 2011/02/14 17:01:19 TestingBrowserProcessTest?
94 public ACProviderListener { 95 public ACProviderListener {
95 public: 96 public:
96 HistoryURLProviderTest() 97 HistoryURLProviderTest()
97 : ui_thread_(BrowserThread::UI, &message_loop_), 98 : ui_thread_(BrowserThread::UI, &message_loop_),
98 file_thread_(BrowserThread::FILE, &message_loop_) {} 99 file_thread_(BrowserThread::FILE, &message_loop_) {}
99 100
100 // ACProviderListener 101 // ACProviderListener
101 virtual void OnProviderUpdate(bool updated_matches); 102 virtual void OnProviderUpdate(bool updated_matches);
102 103
103 protected: 104 protected:
(...skipping 12 matching lines...) Expand all
116 // Runs an autocomplete query on |text| and checks to see that the returned 117 // Runs an autocomplete query on |text| and checks to see that the returned
117 // results' destination URLs match those provided. 118 // results' destination URLs match those provided.
118 void RunTest(const string16 text, 119 void RunTest(const string16 text,
119 const string16& desired_tld, 120 const string16& desired_tld,
120 bool prevent_inline_autocomplete, 121 bool prevent_inline_autocomplete,
121 const std::string* expected_urls, 122 const std::string* expected_urls,
122 size_t num_results); 123 size_t num_results);
123 124
124 void RunAdjustOffsetTest(const string16 text, size_t expected_offset); 125 void RunAdjustOffsetTest(const string16 text, size_t expected_offset);
125 126
127 ScopedTestingBrowserProcess browser_process_;
128
126 MessageLoopForUI message_loop_; 129 MessageLoopForUI message_loop_;
127 BrowserThread ui_thread_; 130 BrowserThread ui_thread_;
128 BrowserThread file_thread_; 131 BrowserThread file_thread_;
129 ACMatches matches_; 132 ACMatches matches_;
130 scoped_ptr<TestingProfile> profile_; 133 scoped_ptr<TestingProfile> profile_;
131 HistoryService* history_service_; 134 HistoryService* history_service_;
132 135
133 private: 136 private:
134 scoped_refptr<HistoryURLProvider> autocomplete_; 137 scoped_refptr<HistoryURLProvider> autocomplete_;
135 }; 138 };
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 std::string navigation_1[] = {"http://test.com/"}; 457 std::string navigation_1[] = {"http://test.com/"};
455 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1, 458 RunTest(ASCIIToUTF16("test.com"), string16(), false, navigation_1,
456 arraysize(navigation_1)); 459 arraysize(navigation_1));
457 460
458 std::string navigation_2[] = {"http://slash/"}; 461 std::string navigation_2[] = {"http://slash/"};
459 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2, 462 RunTest(ASCIIToUTF16("slash"), string16(), false, navigation_2,
460 arraysize(navigation_2)); 463 arraysize(navigation_2));
461 464
462 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0); 465 RunTest(ASCIIToUTF16("this is a query"), string16(), false, NULL, 0);
463 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698