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

Side by Side Diff: trunk/src/chrome/browser/autocomplete/bookmark_provider_unittest.cc

Issue 23551005: Revert 219709 "Remove the Extensions URLRequestContext." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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) 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 "chrome/browser/autocomplete/bookmark_provider.h" 5 #include "chrome/browser/autocomplete/bookmark_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete_provider.h" 16 #include "chrome/browser/autocomplete/autocomplete_provider.h"
17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
18 #include "chrome/browser/bookmarks/bookmark_model.h" 18 #include "chrome/browser/bookmarks/bookmark_model.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 // The bookmark corpus against which we will simulate searches. 23 // The bookmark corpus against which we will simulate searches.
25 struct BookmarksTestInfo { 24 struct BookmarksTestInfo {
26 std::string title; 25 std::string title;
27 std::string url; 26 std::string url;
28 } bookmark_provider_test_data[] = { 27 } bookmark_provider_test_data[] = {
29 { "abc def", "http://www.catsanddogs.com/a" }, 28 { "abc def", "http://www.catsanddogs.com/a" },
30 { "abcde", "http://www.catsanddogs.com/b" }, 29 { "abcde", "http://www.catsanddogs.com/b" },
31 { "abcdef", "http://www.catsanddogs.com/c" }, 30 { "abcdef", "http://www.catsanddogs.com/c" },
(...skipping 24 matching lines...) Expand all
56 public AutocompleteProviderListener { 55 public AutocompleteProviderListener {
57 public: 56 public:
58 BookmarkProviderTest() : model_(new BookmarkModel(NULL)) {} 57 BookmarkProviderTest() : model_(new BookmarkModel(NULL)) {}
59 58
60 // AutocompleteProviderListener: Not called. 59 // AutocompleteProviderListener: Not called.
61 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE {} 60 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE {}
62 61
63 protected: 62 protected:
64 virtual void SetUp() OVERRIDE; 63 virtual void SetUp() OVERRIDE;
65 64
66 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
67 scoped_ptr<TestingProfile> profile_; 65 scoped_ptr<TestingProfile> profile_;
68 scoped_ptr<BookmarkModel> model_; 66 scoped_ptr<BookmarkModel> model_;
69 scoped_refptr<BookmarkProvider> provider_; 67 scoped_refptr<BookmarkProvider> provider_;
70 68
71 private: 69 private:
72 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest); 70 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest);
73 }; 71 };
74 72
75 void BookmarkProviderTest::SetUp() { 73 void BookmarkProviderTest::SetUp() {
76 thread_bundle_.reset(new content::TestBrowserThreadBundle());
77 profile_.reset(new TestingProfile()); 74 profile_.reset(new TestingProfile());
78 DCHECK(profile_.get()); 75 DCHECK(profile_.get());
79 provider_ = new BookmarkProvider(this, profile_.get()); 76 provider_ = new BookmarkProvider(this, profile_.get());
80 DCHECK(provider_.get()); 77 DCHECK(provider_.get());
81 provider_->set_bookmark_model_for_testing(model_.get()); 78 provider_->set_bookmark_model_for_testing(model_.get());
82 79
83 const BookmarkNode* other_node = model_->other_node(); 80 const BookmarkNode* other_node = model_->other_node();
84 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bookmark_provider_test_data); ++i) { 81 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bookmark_provider_test_data); ++i) {
85 const BookmarksTestInfo& cur(bookmark_provider_test_data[i]); 82 const BookmarksTestInfo& cur(bookmark_provider_test_data[i]);
86 const GURL url(cur.url); 83 const GURL url(cur.url);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 << query_data[i].query << "'."; 335 << query_data[i].query << "'.";
339 if (j >= matches.size()) 336 if (j >= matches.size())
340 continue; 337 continue;
341 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description)) 338 EXPECT_EQ(query_data[i].matches[j], UTF16ToUTF8(matches[j].description))
342 << " Mismatch at [" << base::IntToString(j) << "] for query '" 339 << " Mismatch at [" << base::IntToString(j) << "] for query '"
343 << query_data[i].query << "'."; 340 << query_data[i].query << "'.";
344 EXPECT_FALSE(matches[j].allowed_to_be_default_match); 341 EXPECT_FALSE(matches[j].allowed_to_be_default_match);
345 } 342 }
346 } 343 }
347 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698