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

Side by Side Diff: chrome/browser/autocomplete/history_contents_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/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/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
11 #include "chrome/browser/autocomplete/history_contents_provider.h" 11 #include "chrome/browser/autocomplete/history_contents_provider.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/browser_thread.h" 13 #include "chrome/browser/browser_thread.h"
14 #include "chrome/browser/history/history.h" 14 #include "chrome/browser/history/history.h"
15 #include "chrome/test/testing_browser_process.h"
15 #include "chrome/test/testing_profile.h" 16 #include "chrome/test/testing_profile.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using base::Time; 19 using base::Time;
19 using base::TimeDelta; 20 using base::TimeDelta;
20 21
21 namespace { 22 namespace {
22 23
23 struct TestEntry { 24 struct TestEntry {
24 const char* url; 25 const char* url;
25 const char* title; 26 const char* title;
26 const char* body; 27 const char* body;
27 } test_entries[] = { 28 } test_entries[] = {
28 {"http://www.google.com/1", "PAGEONE 1", "FOO some body text"}, 29 {"http://www.google.com/1", "PAGEONE 1", "FOO some body text"},
29 {"http://www.google.com/2", "PAGEONE 2", "FOO some more blah blah"}, 30 {"http://www.google.com/2", "PAGEONE 2", "FOO some more blah blah"},
30 {"http://www.google.com/3", "PAGETHREE 3", "BAR some hello world for you"}, 31 {"http://www.google.com/3", "PAGETHREE 3", "BAR some hello world for you"},
31 }; 32 };
32 33
33 class HistoryContentsProviderTest : public testing::Test, 34 class HistoryContentsProviderTest : public testing::Test,
sky 2011/02/14 17:01:19 TestingBrowserProcessTest?
34 public ACProviderListener { 35 public ACProviderListener {
35 public: 36 public:
36 HistoryContentsProviderTest() 37 HistoryContentsProviderTest()
37 : ui_thread_(BrowserThread::UI, &message_loop_), 38 : ui_thread_(BrowserThread::UI, &message_loop_),
38 file_thread_(BrowserThread::FILE, &message_loop_) {} 39 file_thread_(BrowserThread::FILE, &message_loop_) {}
39 40
40 void RunQuery(const AutocompleteInput& input, 41 void RunQuery(const AutocompleteInput& input,
41 bool minimal_changes) { 42 bool minimal_changes) {
42 provider_->Start(input, minimal_changes); 43 provider_->Start(input, minimal_changes);
43 44
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 90 }
90 91
91 // ACProviderListener 92 // ACProviderListener
92 virtual void OnProviderUpdate(bool updated_matches) { 93 virtual void OnProviderUpdate(bool updated_matches) {
93 // We must quit the message loop (if running) to return control to the test. 94 // We must quit the message loop (if running) to return control to the test.
94 // Note, calling Quit() directly will checkfail if the loop isn't running, 95 // Note, calling Quit() directly will checkfail if the loop isn't running,
95 // so we post a task, which is safe for either case. 96 // so we post a task, which is safe for either case.
96 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 97 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
97 } 98 }
98 99
100 ScopedTestingBrowserProcess browser_process_;
101
99 MessageLoopForUI message_loop_; 102 MessageLoopForUI message_loop_;
100 BrowserThread ui_thread_; 103 BrowserThread ui_thread_;
101 BrowserThread file_thread_; 104 BrowserThread file_thread_;
102 105
103 scoped_ptr<TestingProfile> profile_; 106 scoped_ptr<TestingProfile> profile_;
104 scoped_refptr<HistoryContentsProvider> provider_; 107 scoped_refptr<HistoryContentsProvider> provider_;
105 }; 108 };
106 109
107 TEST_F(HistoryContentsProviderTest, Body) { 110 TEST_F(HistoryContentsProviderTest, Body) {
108 AutocompleteInput input(ASCIIToUTF16("FOO"), string16(), true, false, true, 111 AutocompleteInput input(ASCIIToUTF16("FOO"), string16(), true, false, true,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 true, false); 243 true, false);
241 RunQuery(you_input, false); 244 RunQuery(you_input, false);
242 EXPECT_EQ(0U, matches().size()); 245 EXPECT_EQ(0U, matches().size());
243 246
244 // Run a query that matches the bookmark 247 // Run a query that matches the bookmark
245 RunQuery(input, false); 248 RunQuery(input, false);
246 EXPECT_EQ(1U, matches().size()); 249 EXPECT_EQ(1U, matches().size());
247 } 250 }
248 251
249 } // namespace 252 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698