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

Side by Side Diff: chrome/browser/autocomplete/search_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) 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "chrome/browser/autocomplete/search_provider.h" 10 #include "chrome/browser/autocomplete/search_provider.h"
11 #include "chrome/browser/browser_thread.h" 11 #include "chrome/browser/browser_thread.h"
12 #include "chrome/browser/history/history.h" 12 #include "chrome/browser/history/history.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/search_engines/template_url.h" 14 #include "chrome/browser/search_engines/template_url.h"
15 #include "chrome/browser/search_engines/template_url_model.h" 15 #include "chrome/browser/search_engines/template_url_model.h"
16 #include "chrome/common/net/test_url_fetcher_factory.h" 16 #include "chrome/common/net/test_url_fetcher_factory.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/testing_browser_process.h"
18 #include "chrome/test/testing_profile.h" 19 #include "chrome/test/testing_profile.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 // The following environment is configured for these tests: 23 // The following environment is configured for these tests:
23 // . The TemplateURL default_t_url_ is set as the default provider. 24 // . The TemplateURL default_t_url_ is set as the default provider.
24 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This 25 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This
25 // TemplateURL has a valid suggest and search URL. 26 // TemplateURL has a valid suggest and search URL.
26 // . The URL created by using the search term term1_ with default_t_url_ is 27 // . The URL created by using the search term term1_ with default_t_url_ is
27 // added to history. 28 // added to history.
28 // . The URL created by using the search term keyword_term_ with keyword_t_url_ 29 // . The URL created by using the search term keyword_term_ with keyword_t_url_
29 // is added to history. 30 // is added to history.
30 // . test_factory_ is set as the URLFetcher::Factory. 31 // . test_factory_ is set as the URLFetcher::Factory.
31 class SearchProviderTest : public testing::Test, 32 class SearchProviderTest : public testing::Test,
sky 2011/02/14 17:01:19 TestingBrowserProcessTest?
32 public AutocompleteProvider::ACProviderListener { 33 public AutocompleteProvider::ACProviderListener {
33 public: 34 public:
34 SearchProviderTest() 35 SearchProviderTest()
35 : default_t_url_(NULL), 36 : default_t_url_(NULL),
36 term1_(UTF8ToUTF16("term1")), 37 term1_(UTF8ToUTF16("term1")),
37 keyword_t_url_(NULL), 38 keyword_t_url_(NULL),
38 keyword_term_(UTF8ToUTF16("keyword")), 39 keyword_term_(UTF8ToUTF16("keyword")),
39 io_thread_(BrowserThread::IO), 40 io_thread_(BrowserThread::IO),
40 quit_when_done_(false) { 41 quit_when_done_(false) {
41 io_thread_.Start(); 42 io_thread_.Start();
(...skipping 20 matching lines...) Expand all
62 // Invokes Start on provider_, then runs all pending tasks. 63 // Invokes Start on provider_, then runs all pending tasks.
63 void QueryForInput(const string16& text, 64 void QueryForInput(const string16& text,
64 bool prevent_inline_autocomplete, 65 bool prevent_inline_autocomplete,
65 bool minimal_changes); 66 bool minimal_changes);
66 67
67 // Notifies the URLFetcher for the suggest query corresponding to the default 68 // Notifies the URLFetcher for the suggest query corresponding to the default
68 // search provider that it's done. 69 // search provider that it's done.
69 // Be sure and wrap calls to this in ASSERT_NO_FATAL_FAILURE. 70 // Be sure and wrap calls to this in ASSERT_NO_FATAL_FAILURE.
70 void FinishDefaultSuggestQuery(); 71 void FinishDefaultSuggestQuery();
71 72
73 ScopedTestingBrowserProcess browser_process_;
74
72 // See description above class for details of these fields. 75 // See description above class for details of these fields.
73 TemplateURL* default_t_url_; 76 TemplateURL* default_t_url_;
74 const string16 term1_; 77 const string16 term1_;
75 GURL term1_url_; 78 GURL term1_url_;
76 TemplateURL* keyword_t_url_; 79 TemplateURL* keyword_t_url_;
77 const string16 keyword_term_; 80 const string16 keyword_term_;
78 GURL keyword_url_; 81 GURL keyword_url_;
79 82
80 MessageLoopForUI message_loop_; 83 MessageLoopForUI message_loop_;
81 BrowserThread io_thread_; 84 BrowserThread io_thread_;
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // originally supplied. 447 // originally supplied.
445 QueryForInput(ASCIIToUTF16("foo "), false, true); 448 QueryForInput(ASCIIToUTF16("foo "), false, true);
446 449
447 // There should only one match, for what you typed. 450 // There should only one match, for what you typed.
448 EXPECT_EQ(1u, provider_->matches().size()); 451 EXPECT_EQ(1u, provider_->matches().size());
449 GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms( 452 GURL instant_url = GURL(default_t_url_->url()->ReplaceSearchTerms(
450 *default_t_url_, ASCIIToUTF16("foo"), 0, string16())); 453 *default_t_url_, ASCIIToUTF16("foo"), 0, string16()));
451 AutocompleteMatch instant_match = FindMatchWithDestination(instant_url); 454 AutocompleteMatch instant_match = FindMatchWithDestination(instant_url);
452 EXPECT_FALSE(instant_match.destination_url.is_empty()); 455 EXPECT_FALSE(instant_match.destination_url.is_empty());
453 } 456 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698