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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_controller_unittest.cc

Issue 15003002: Omnibox refactor. Move StartAutocomplete and DoInstant to controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted dummy test. Created 7 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "chrome/browser/autocomplete/autocomplete_controller.h" 6 #include "chrome/browser/autocomplete/autocomplete_controller.h"
7 #include "chrome/browser/autocomplete/autocomplete_provider.h" 7 #include "chrome/browser/autocomplete/autocomplete_provider.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/browser/ui/omnibox/omnibox_controller.h" 9 #include "chrome/browser/ui/omnibox/omnibox_controller.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace {
15
16 class OmniboxControllerTest : public testing::Test { 14 class OmniboxControllerTest : public testing::Test {
17 protected: 15 protected:
18 OmniboxControllerTest(); 16 OmniboxControllerTest();
19 virtual ~OmniboxControllerTest(); 17 virtual ~OmniboxControllerTest();
20 18
21 void CreateController(); 19 void CreateController();
22 void AssertProviders(int expected_providers); 20 void AssertProviders(int expected_providers);
23 21
24 PrefService* GetPrefs() { return profile_.GetPrefs(); } 22 PrefService* GetPrefs() { return profile_.GetPrefs(); }
25 const ACProviders* GetAutocompleteProviders() const { 23 const ACProviders* GetAutocompleteProviders() const {
26 return omnibox_controller_->autocomplete_controller()->providers(); 24 return omnibox_controller_->autocomplete_controller()->providers();
27 } 25 }
28 26
29 private: 27 private:
30 TestingProfile profile_; 28 TestingProfile profile_;
31 scoped_ptr<OmniboxController> omnibox_controller_; 29 scoped_ptr<OmniboxController> omnibox_controller_;
32 30
33 DISALLOW_COPY_AND_ASSIGN(OmniboxControllerTest); 31 DISALLOW_COPY_AND_ASSIGN(OmniboxControllerTest);
34 }; 32 };
35 33
36 OmniboxControllerTest::OmniboxControllerTest() { 34 OmniboxControllerTest::OmniboxControllerTest() {
37 } 35 }
38 36
39 OmniboxControllerTest::~OmniboxControllerTest() { 37 OmniboxControllerTest::~OmniboxControllerTest() {
40 } 38 }
41 39
42 void OmniboxControllerTest::CreateController() { 40 void OmniboxControllerTest::CreateController() {
43 omnibox_controller_.reset(new OmniboxController(NULL, &profile_)); 41 omnibox_controller_.reset(new OmniboxController(NULL, &profile_, NULL));
44 } 42 }
45 43
46 // Checks that the list of autocomplete providers used by the OmniboxController 44 // Checks that the list of autocomplete providers used by the OmniboxController
47 // matches the one in the |expected_providers| bit field. 45 // matches the one in the |expected_providers| bit field.
48 void OmniboxControllerTest::AssertProviders(int expected_providers) { 46 void OmniboxControllerTest::AssertProviders(int expected_providers) {
49 const ACProviders* providers = GetAutocompleteProviders(); 47 const ACProviders* providers = GetAutocompleteProviders();
50 48
51 for (size_t i = 0; i < providers->size(); ++i) { 49 for (size_t i = 0; i < providers->size(); ++i) {
52 // Ensure this is a provider we wanted. 50 // Ensure this is a provider we wanted.
53 int type = providers->at(i)->type(); 51 int type = providers->at(i)->type();
(...skipping 30 matching lines...) Expand all
84 // not expected to run in instant extended. 82 // not expected to run in instant extended.
85 int providers_with_instant_extended = 83 int providers_with_instant_extended =
86 observed_providers & 84 observed_providers &
87 ~AutocompleteProvider::TYPE_HISTORY_CONTENTS & 85 ~AutocompleteProvider::TYPE_HISTORY_CONTENTS &
88 ~AutocompleteProvider::TYPE_SHORTCUTS; 86 ~AutocompleteProvider::TYPE_SHORTCUTS;
89 // TODO(beaudoin): remove TYPE_SEARCH once it's no longer needed to pass 87 // TODO(beaudoin): remove TYPE_SEARCH once it's no longer needed to pass
90 // the Instant suggestion through via FinalizeInstantQuery. 88 // the Instant suggestion through via FinalizeInstantQuery.
91 chrome::EnableInstantExtendedAPIForTesting(); 89 chrome::EnableInstantExtendedAPIForTesting();
92 CreateController(); 90 CreateController();
93 AssertProviders(providers_with_instant_extended); 91 AssertProviders(providers_with_instant_extended);
94
95 } 92 }
96
97 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698