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

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

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | chrome/browser/browser_main.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/autocomplete/search_provider.h" 8 #include "chrome/browser/autocomplete/search_provider.h"
9 #include "chrome/browser/chrome_thread.h"
9 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
10 #include "chrome/browser/net/test_url_fetcher_factory.h" 11 #include "chrome/browser/net/test_url_fetcher_factory.h"
11 #include "chrome/browser/search_engines/template_url.h" 12 #include "chrome/browser/search_engines/template_url.h"
12 #include "chrome/browser/search_engines/template_url_model.h" 13 #include "chrome/browser/search_engines/template_url_model.h"
13 #include "chrome/test/testing_profile.h" 14 #include "chrome/test/testing_profile.h"
14 #include "net/url_request/url_request_status.h" 15 #include "net/url_request/url_request_status.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 // The following environment is configured for these tests: 18 // The following environment is configured for these tests:
18 // . The TemplateURL default_t_url_ is set as the default provider. 19 // . The TemplateURL default_t_url_ is set as the default provider.
19 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This 20 // . The TemplateURL keyword_t_url_ is added to the TemplateURLModel. This
20 // TemplateURL has a valid suggest and search URL. 21 // TemplateURL has a valid suggest and search URL.
21 // . The URL created by using the search term term1_ with default_t_url_ is 22 // . The URL created by using the search term term1_ with default_t_url_ is
22 // added to history. 23 // added to history.
23 // . The URL created by using the search term keyword_term_ with keyword_t_url_ 24 // . The URL created by using the search term keyword_term_ with keyword_t_url_
24 // is added to history. 25 // is added to history.
25 // . test_factory_ is set as the URLFetcher::Factory. 26 // . test_factory_ is set as the URLFetcher::Factory.
26 class SearchProviderTest : public testing::Test, 27 class SearchProviderTest : public testing::Test,
27 public AutocompleteProvider::ACProviderListener { 28 public AutocompleteProvider::ACProviderListener {
28 public: 29 public:
29 SearchProviderTest() 30 SearchProviderTest()
30 : default_t_url_(NULL), 31 : default_t_url_(NULL),
31 term1_(L"term1"), 32 term1_(L"term1"),
32 keyword_t_url_(NULL), 33 keyword_t_url_(NULL),
33 keyword_term_(L"keyword"), 34 keyword_term_(L"keyword"),
34 quit_when_done_(false) {} 35 io_thread_(ChromeThread::IO),
darin (slow to review) 2009/10/27 00:06:52 does this test thread need to be a real IO thread?
jam 2009/10/27 02:38:18 It already had a MessageLoopForUI before. I just
jam 2009/10/27 02:46:29 oops, I realize what you mean now. I needed a Chr
darin (slow to review) 2009/10/27 04:43:33 OK
36 quit_when_done_(false) {
37 io_thread_.Start();
38 }
35 39
36 // See description above class for what this registers. 40 // See description above class for what this registers.
37 virtual void SetUp(); 41 virtual void SetUp();
38 42
39 virtual void TearDown(); 43 virtual void TearDown();
40 44
41 protected: 45 protected:
42 // Returns an AutocompleteMatch in provider_'s set of matches that matches 46 // Returns an AutocompleteMatch in provider_'s set of matches that matches
43 // |url|. If there is no matching URL, an empty match is returned. 47 // |url|. If there is no matching URL, an empty match is returned.
44 AutocompleteMatch FindMatchWithDestination(const GURL& url); 48 AutocompleteMatch FindMatchWithDestination(const GURL& url);
(...skipping 10 matching lines...) Expand all
55 void QueryForInput(const std::wstring& text); 59 void QueryForInput(const std::wstring& text);
56 60
57 // See description above class for details of these fields. 61 // See description above class for details of these fields.
58 TemplateURL* default_t_url_; 62 TemplateURL* default_t_url_;
59 const std::wstring term1_; 63 const std::wstring term1_;
60 GURL term1_url_; 64 GURL term1_url_;
61 TemplateURL* keyword_t_url_; 65 TemplateURL* keyword_t_url_;
62 const std::wstring keyword_term_; 66 const std::wstring keyword_term_;
63 GURL keyword_url_; 67 GURL keyword_url_;
64 68
69 MessageLoopForUI message_loop_;
70 ChromeThread io_thread_;
71
65 // URLFetcher::Factory implementation registered. 72 // URLFetcher::Factory implementation registered.
66 TestURLFetcherFactory test_factory_; 73 TestURLFetcherFactory test_factory_;
67 74
68 MessageLoopForUI message_loop_;
69
70 // Profile we use. 75 // Profile we use.
71 TestingProfile profile_; 76 TestingProfile profile_;
72 77
73 // The provider. 78 // The provider.
74 scoped_refptr<SearchProvider> provider_; 79 scoped_refptr<SearchProvider> provider_;
75 80
76 // If true, OnProviderUpdate exits out of the current message loop. 81 // If true, OnProviderUpdate exits out of the current message loop.
77 bool quit_when_done_; 82 bool quit_when_done_;
78 83
79 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); 84 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 AutocompleteMatch match = FindMatchWithDestination(keyword_url_); 257 AutocompleteMatch match = FindMatchWithDestination(keyword_url_);
253 ASSERT_TRUE(!match.destination_url.is_empty()); 258 ASSERT_TRUE(!match.destination_url.is_empty());
254 259
255 // The match should have a TemplateURL. 260 // The match should have a TemplateURL.
256 EXPECT_TRUE(match.template_url); 261 EXPECT_TRUE(match.template_url);
257 262
258 // The fill into edit should contain the keyword. 263 // The fill into edit should contain the keyword.
259 EXPECT_EQ(keyword_t_url_->keyword() + L" " + keyword_term_, 264 EXPECT_EQ(keyword_t_url_->keyword() + L" " + keyword_term_,
260 match.fill_into_edit); 265 match.fill_into_edit);
261 } 266 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | chrome/browser/browser_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698