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

Side by Side Diff: chrome/browser/search_engines/search_host_to_urls_map_unittest.cc

Issue 344083003: Stop using UIThreadSearchTermsData in tests when unnecessary (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/search_engines/search_host_to_urls_map.h" 7 #include "chrome/browser/search_engines/search_host_to_urls_map.h"
8 #include "chrome/browser/search_engines/template_url.h" 8 #include "chrome/browser/search_engines/template_url.h"
9 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 9 #include "components/search_engines/search_terms_data.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; 12 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet;
13 13
14 // Basic functionality for the SearchHostToURLsMap tests. 14 // Basic functionality for the SearchHostToURLsMap tests.
15 class SearchHostToURLsMapTest : public testing::Test { 15 class SearchHostToURLsMapTest : public testing::Test {
16 public: 16 public:
17 SearchHostToURLsMapTest() {} 17 SearchHostToURLsMapTest() {}
18 18
19 virtual void SetUp(); 19 virtual void SetUp();
(...skipping 12 matching lines...) Expand all
32 TemplateURLData data; 32 TemplateURLData data;
33 data.SetURL("http://" + host_ + "/path1"); 33 data.SetURL("http://" + host_ + "/path1");
34 t_urls_[0].reset(new TemplateURL(data)); 34 t_urls_[0].reset(new TemplateURL(data));
35 data.SetURL("http://" + host_ + "/path2"); 35 data.SetURL("http://" + host_ + "/path2");
36 t_urls_[1].reset(new TemplateURL(data)); 36 t_urls_[1].reset(new TemplateURL(data));
37 std::vector<TemplateURL*> template_urls; 37 std::vector<TemplateURL*> template_urls;
38 template_urls.push_back(t_urls_[0].get()); 38 template_urls.push_back(t_urls_[0].get());
39 template_urls.push_back(t_urls_[1].get()); 39 template_urls.push_back(t_urls_[1].get());
40 40
41 provider_map_.reset(new SearchHostToURLsMap); 41 provider_map_.reset(new SearchHostToURLsMap);
42 UIThreadSearchTermsData search_terms_data(NULL); 42 provider_map_->Init(template_urls, SearchTermsData());
43 provider_map_->Init(template_urls, search_terms_data);
44 } 43 }
45 44
46 TEST_F(SearchHostToURLsMapTest, Add) { 45 TEST_F(SearchHostToURLsMapTest, Add) {
47 std::string new_host = "example.com"; 46 std::string new_host = "example.com";
48 TemplateURLData data; 47 TemplateURLData data;
49 data.SetURL("http://" + new_host + "/"); 48 data.SetURL("http://" + new_host + "/");
50 TemplateURL new_t_url(data); 49 TemplateURL new_t_url(data);
51 UIThreadSearchTermsData search_terms_data(NULL); 50 provider_map_->Add(&new_t_url, SearchTermsData());
52 provider_map_->Add(&new_t_url, search_terms_data);
53 51
54 ASSERT_EQ(&new_t_url, provider_map_->GetTemplateURLForHost(new_host)); 52 ASSERT_EQ(&new_t_url, provider_map_->GetTemplateURLForHost(new_host));
55 } 53 }
56 54
57 TEST_F(SearchHostToURLsMapTest, Remove) { 55 TEST_F(SearchHostToURLsMapTest, Remove) {
58 UIThreadSearchTermsData search_terms_data(NULL); 56 provider_map_->Remove(t_urls_[0].get(), SearchTermsData());
59 provider_map_->Remove(t_urls_[0].get(), search_terms_data);
60 57
61 const TemplateURL* found_url = provider_map_->GetTemplateURLForHost(host_); 58 const TemplateURL* found_url = provider_map_->GetTemplateURLForHost(host_);
62 ASSERT_EQ(t_urls_[1].get(), found_url); 59 ASSERT_EQ(t_urls_[1].get(), found_url);
63 60
64 const TemplateURLSet* urls = provider_map_->GetURLsForHost(host_); 61 const TemplateURLSet* urls = provider_map_->GetURLsForHost(host_);
65 ASSERT_TRUE(urls != NULL); 62 ASSERT_TRUE(urls != NULL);
66 63
67 int url_count = 0; 64 int url_count = 0;
68 for (TemplateURLSet::const_iterator i(urls->begin()); i != urls->end(); ++i) { 65 for (TemplateURLSet::const_iterator i(urls->begin()); i != urls->end(); ++i) {
69 url_count++; 66 url_count++;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 98
102 for (size_t i = 0; i < arraysize(found_urls); ++i) 99 for (size_t i = 0; i < arraysize(found_urls); ++i)
103 ASSERT_TRUE(found_urls[i]); 100 ASSERT_TRUE(found_urls[i]);
104 } 101 }
105 102
106 TEST_F(SearchHostToURLsMapTest, GetURLsForUnknownHost) { 103 TEST_F(SearchHostToURLsMapTest, GetURLsForUnknownHost) {
107 const SearchHostToURLsMap::TemplateURLSet* urls = 104 const SearchHostToURLsMap::TemplateURLSet* urls =
108 provider_map_->GetURLsForHost("a" + host_); 105 provider_map_->GetURLsForHost("a" + host_);
109 ASSERT_TRUE(urls == NULL); 106 ASSERT_TRUE(urls == NULL);
110 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698