This source file includes following definitions.
- GetPrefs
- GetAutocompleteProviders
- CreateController
- AssertProviders
- TEST_F
#include "base/prefs/pref_service.h"
#include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_provider.h"
#include "chrome/browser/ui/omnibox/omnibox_controller.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
class OmniboxControllerTest : public testing::Test {
protected:
OmniboxControllerTest();
virtual ~OmniboxControllerTest();
void CreateController();
void AssertProviders(int expected_providers);
PrefService* GetPrefs() { return profile_.GetPrefs(); }
const ACProviders* GetAutocompleteProviders() const {
return omnibox_controller_->autocomplete_controller()->providers();
}
private:
TestingProfile profile_;
scoped_ptr<OmniboxController> omnibox_controller_;
DISALLOW_COPY_AND_ASSIGN(OmniboxControllerTest);
};
OmniboxControllerTest::OmniboxControllerTest() {
}
OmniboxControllerTest::~OmniboxControllerTest() {
}
void OmniboxControllerTest::CreateController() {
omnibox_controller_.reset(new OmniboxController(NULL, &profile_));
}
void OmniboxControllerTest::AssertProviders(int expected_providers) {
const ACProviders* providers = GetAutocompleteProviders();
for (size_t i = 0; i < providers->size(); ++i) {
int type = providers->at(i)->type();
ASSERT_TRUE(expected_providers & type);
expected_providers &= ~type;
}
ASSERT_EQ(0, expected_providers);
}
TEST_F(OmniboxControllerTest, CheckDefaultAutocompleteProviders) {
CreateController();
int observed_providers = 0;
const ACProviders* providers = GetAutocompleteProviders();
for (size_t i = 0; i < providers->size(); ++i)
observed_providers |= providers->at(i)->type();
ASSERT_NE(0, observed_providers);
int providers_with_instant_extended = observed_providers;
CreateController();
AssertProviders(providers_with_instant_extended);
}