Commit 455a5fcd authored by Maajid's avatar Maajid Committed by Commit Bot

Reland: Use the magnifying glass icon instead of the Google icon for the...

Reland: Use the magnifying glass icon instead of the Google icon for the search box when the default search provider is not Google.

Bug:736038
TEST:unit tested, device tested with --enable-features=EnableFullcreenAppList, ASAN and LSAN local test.

The fix for the ASAN failure was to use unique_ptr for the search_box_view pointer in the unit test.

Change-Id: Id6026f6193a87f48d44064315ddde5e436d7d333
Reviewed-on: https://chromium-review.googlesource.com/571310
Commit-Queue: Maajid <maajid@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486901}
parent 4d1e08b8
...@@ -289,6 +289,7 @@ test("app_list_unittests") { ...@@ -289,6 +289,7 @@ test("app_list_unittests") {
] ]
deps += [ deps += [
"//ui/accessibility", "//ui/accessibility",
"//ui/app_list/vector_icons",
"//ui/views", "//ui/views",
"//ui/views:test_support", "//ui/views:test_support",
] ]
......
...@@ -166,6 +166,14 @@ const char kSearchResultDistanceFromOrigin[] = ...@@ -166,6 +166,14 @@ const char kSearchResultDistanceFromOrigin[] =
// The height of tiles in search result. // The height of tiles in search result.
const int kSearchTileHeight = 92; const int kSearchTileHeight = 92;
// The size of the search icon in the search box.
const int kSearchIconSize = 24;
// Default color used when wallpaper customized color is not available for
// searchbox, #000 at 87% opacity.
const SkColor kDefaultSearchboxColor =
SkColorSetARGBMacro(0xDE, 0x00, 0x00, 0x00);
gfx::ShadowValue GetShadowForZHeight(int z_height) { gfx::ShadowValue GetShadowForZHeight(int z_height) {
if (z_height <= 0) if (z_height <= 0)
return gfx::ShadowValue(); return gfx::ShadowValue();
......
...@@ -112,6 +112,9 @@ APP_LIST_EXPORT extern const char kSearchResultDistanceFromOrigin[]; ...@@ -112,6 +112,9 @@ APP_LIST_EXPORT extern const char kSearchResultDistanceFromOrigin[];
APP_LIST_EXPORT extern const int kSearchTileHeight; APP_LIST_EXPORT extern const int kSearchTileHeight;
APP_LIST_EXPORT extern const int kSearchIconSize;
APP_LIST_EXPORT extern const SkColor kDefaultSearchboxColor;
// Returns the shadow values for a view at |z_height|. // Returns the shadow values for a view at |z_height|.
APP_LIST_EXPORT gfx::ShadowValue GetShadowForZHeight(int z_height); APP_LIST_EXPORT gfx::ShadowValue GetShadowForZHeight(int z_height);
......
...@@ -89,5 +89,9 @@ void AppListTestViewDelegate::ReplaceTestModel(int item_count) { ...@@ -89,5 +89,9 @@ void AppListTestViewDelegate::ReplaceTestModel(int item_count) {
model_->PopulateApps(item_count); model_->PopulateApps(item_count);
} }
void AppListTestViewDelegate::SetSearchEngineIsGoogle(bool is_google) {
model_->SetSearchEngineIsGoogle(is_google);
}
} // namespace test } // namespace test
} // namespace app_list } // namespace app_list
...@@ -47,6 +47,9 @@ class AppListTestViewDelegate : public AppListViewDelegate { ...@@ -47,6 +47,9 @@ class AppListTestViewDelegate : public AppListViewDelegate {
// value to 0. // value to 0.
int GetStopSpeechRecognitionCountAndReset(); int GetStopSpeechRecognitionCountAndReset();
// Sets whether the search engine is Google or not.
void SetSearchEngineIsGoogle(bool is_google);
// AppListViewDelegate overrides: // AppListViewDelegate overrides:
AppListModel* GetModel() override; AppListModel* GetModel() override;
SpeechUIModel* GetSpeechUI() override; SpeechUIModel* GetSpeechUI() override;
......
...@@ -22,6 +22,8 @@ aggregate_vector_icons("app_list_vector_icons") { ...@@ -22,6 +22,8 @@ aggregate_vector_icons("app_list_vector_icons") {
"ic_google_black.icon", "ic_google_black.icon",
"ic_mic_black.1x.icon", "ic_mic_black.1x.icon",
"ic_mic_black.icon", "ic_mic_black.icon",
"ic_search_engine_not_google.1x.icon",
"ic_search_engine_not_google.icon",
] ]
} }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 24,
MOVE_TO, 15.5f, 14,
LINE_TO, 14.71f, 14,
LINE_TO, 14.43f, 13.73f,
CUBIC_TO, 15.41f, 12.59f, 16, 11.11f, 16, 9.5f,
CUBIC_TO, 16, 5.91f, 13.09f, 3, 9.5f, 3,
CUBIC_TO, 5.91f, 3, 3, 5.91f, 3, 9.5f,
CUBIC_TO, 3, 13.09f, 5.91f, 16, 9.5f, 16,
CUBIC_TO, 11.11f, 16, 12.59f, 15.41f, 13.73f, 14.43f,
LINE_TO, 14, 14.71f,
LINE_TO, 14, 15.5f,
LINE_TO, 19, 20.49f,
LINE_TO, 20.49f, 19,
LINE_TO, 15.5f, 14,
CLOSE,
MOVE_TO, 9.5f, 14,
CUBIC_TO, 7.01f, 14, 5, 11.99f, 5, 9.5f,
CUBIC_TO, 5, 7.01f, 7.01f, 5, 9.5f, 5,
CUBIC_TO, 11.99f, 5, 14, 7.01f, 14, 9.5f,
CUBIC_TO, 14, 11.99f, 11.99f, 14, 9.5f, 14,
CLOSE,
END
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
MOVE_TO, 31, 28,
LINE_TO, 29.42f, 28,
LINE_TO, 28.86f, 27.46f,
CUBIC_TO, 30.82f, 25.18f, 32, 22.22f, 32, 19,
CUBIC_TO, 32, 11.82f, 26.18f, 6, 19, 6,
CUBIC_TO, 11.82f, 6, 6, 11.82f, 6, 19,
CUBIC_TO, 6, 26.18f, 11.82f, 32, 19, 32,
CUBIC_TO, 22.22f, 32, 25.18f, 30.82f, 27.46f, 28.86f,
LINE_TO, 28, 29.42f,
LINE_TO, 28, 31,
LINE_TO, 38, 40.98f,
LINE_TO, 40.98f, 38,
LINE_TO, 31, 28,
CLOSE,
MOVE_TO, 19, 28,
CUBIC_TO, 14.02f, 28, 10, 23.98f, 10, 19,
CUBIC_TO, 10, 14.02f, 14.02f, 10, 19, 10,
CUBIC_TO, 23.98f, 10, 28, 14.02f, 28, 19,
CUBIC_TO, 28, 23.98f, 23.98f, 28, 19, 28,
CLOSE,
END
...@@ -57,15 +57,9 @@ constexpr SkColor kHintTextColor = SkColorSetARGBMacro(0xFF, 0xA0, 0xA0, 0xA0); ...@@ -57,15 +57,9 @@ constexpr SkColor kHintTextColor = SkColorSetARGBMacro(0xFF, 0xA0, 0xA0, 0xA0);
constexpr int kSearchBoxBorderCornerRadius = 2; constexpr int kSearchBoxBorderCornerRadius = 2;
constexpr int kSearchBoxBorderCornerRadiusSearchResult = 4; constexpr int kSearchBoxBorderCornerRadiusSearchResult = 4;
constexpr int kGoogleIconSize = 24;
constexpr int kMicIconSize = 24; constexpr int kMicIconSize = 24;
constexpr int kCloseIconSize = 24; constexpr int kCloseIconSize = 24;
// Default color used when wallpaper customized color is not available for
// searchbox, #000 at 87% opacity.
constexpr SkColor kDefaultSearchboxColor =
SkColorSetARGBMacro(0xDE, 0x00, 0x00, 0x00);
constexpr int kLightVibrantBlendAlpha = 0xB3; constexpr int kLightVibrantBlendAlpha = 0xB3;
// Color of placeholder text in zero query state. // Color of placeholder text in zero query state.
...@@ -193,11 +187,10 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, ...@@ -193,11 +187,10 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
content_container_->AddChildView(back_button_); content_container_->AddChildView(back_button_);
if (is_fullscreen_app_list_enabled_) { if (is_fullscreen_app_list_enabled_) {
google_icon_ = new views::ImageView(); search_icon_ = new views::ImageView();
google_icon_->SetImage(gfx::CreateVectorIcon( UpdateSearchIcon(view_delegate_->GetModel()->search_engine_is_google(),
kIcGoogleBlackIcon, kGoogleIconSize, kDefaultSearchboxColor)); kDefaultSearchboxColor);
content_container_->AddChildView(google_icon_); content_container_->AddChildView(search_icon_);
search_box_->set_placeholder_text_color(kDefaultSearchboxColor); search_box_->set_placeholder_text_color(kDefaultSearchboxColor);
search_box_->set_placeholder_text_draw_flags( search_box_->set_placeholder_text_draw_flags(
gfx::Canvas::TEXT_ALIGN_CENTER); gfx::Canvas::TEXT_ALIGN_CENTER);
...@@ -234,6 +227,8 @@ void SearchBoxView::ModelChanged() { ...@@ -234,6 +227,8 @@ void SearchBoxView::ModelChanged() {
model_ = view_delegate_->GetModel(); model_ = view_delegate_->GetModel();
DCHECK(model_); DCHECK(model_);
if (is_fullscreen_app_list_enabled_)
UpdateSearchIcon(model_->search_engine_is_google(), kDefaultSearchboxColor);
model_->search_box()->AddObserver(this); model_->search_box()->AddObserver(this);
SpeechRecognitionButtonPropChanged(); SpeechRecognitionButtonPropChanged();
HintTextChanged(); HintTextChanged();
...@@ -380,7 +375,7 @@ void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) { ...@@ -380,7 +375,7 @@ void SearchBoxView::ShowBackOrGoogleIcon(bool show_back_button) {
if (!is_fullscreen_app_list_enabled_) if (!is_fullscreen_app_list_enabled_)
return; return;
google_icon_->SetVisible(!show_back_button); search_icon_->SetVisible(!show_back_button);
back_button_->SetVisible(show_back_button); back_button_->SetVisible(show_back_button);
content_container_->Layout(); content_container_->Layout();
} }
...@@ -684,36 +679,27 @@ void SearchBoxView::WallpaperProminentColorsChanged() { ...@@ -684,36 +679,27 @@ void SearchBoxView::WallpaperProminentColorsChanged() {
prominent_colors.size()); prominent_colors.size());
const SkColor dark_muted = const SkColor dark_muted =
prominent_colors[static_cast<int>(ColorProfileType::DARK_MUTED)]; prominent_colors[static_cast<int>(ColorProfileType::DARK_MUTED)];
const bool dark_muted_available = SK_ColorTRANSPARENT != dark_muted; const SkColor search_box_color =
google_icon_->SetImage(gfx::CreateVectorIcon( SK_ColorTRANSPARENT == dark_muted ? kDefaultSearchboxColor : dark_muted;
kIcGoogleBlackIcon, kGoogleIconSize, UpdateSearchIcon(model_->search_engine_is_google(), search_box_color);
dark_muted_available ? dark_muted : kDefaultSearchboxColor));
speech_button_->SetImage( speech_button_->SetImage(
views::Button::STATE_NORMAL, views::Button::STATE_NORMAL,
gfx::CreateVectorIcon( gfx::CreateVectorIcon(kIcMicBlackIcon, kMicIconSize, search_box_color));
kIcMicBlackIcon, kMicIconSize,
dark_muted_available ? dark_muted : kDefaultSearchboxColor));
close_button_->SetImage( close_button_->SetImage(
views::Button::STATE_NORMAL, views::Button::STATE_NORMAL,
gfx::CreateVectorIcon( gfx::CreateVectorIcon(kIcCloseIcon, kCloseIconSize, search_box_color));
kIcCloseIcon, kCloseIconSize, search_box_->set_placeholder_text_color(search_box_color);
dark_muted_available ? dark_muted : kDefaultSearchboxColor));
search_box_->set_placeholder_text_color(
dark_muted_available ? dark_muted : kDefaultSearchboxColor);
const SkColor light_vibrant = const SkColor light_vibrant =
prominent_colors[static_cast<int>(ColorProfileType::LIGHT_VIBRANT)]; prominent_colors[static_cast<int>(ColorProfileType::LIGHT_VIBRANT)];
const SkColor light_vibrant_mixed = color_utils::AlphaBlend( const SkColor light_vibrant_mixed = color_utils::AlphaBlend(
SK_ColorWHITE, light_vibrant, kLightVibrantBlendAlpha); SK_ColorWHITE, light_vibrant, kLightVibrantBlendAlpha);
const bool light_vibrant_available = SK_ColorTRANSPARENT != light_vibrant; const SkColor background_color = SK_ColorTRANSPARENT == light_vibrant
? kSearchBoxBackgroundDefault
: light_vibrant_mixed;
SearchBoxBackground* background = SearchBoxBackground* background =
static_cast<SearchBoxBackground*>(content_container_->background()); static_cast<SearchBoxBackground*>(content_container_->background());
background->set_color(light_vibrant_available ? light_vibrant_mixed background->set_color(background_color);
: kSearchBoxBackgroundDefault); search_box_->SetBackgroundColor(background_color);
search_box_->SetBackgroundColor(light_vibrant_available
? light_vibrant_mixed
: kSearchBoxBackgroundDefault);
SchedulePaint(); SchedulePaint();
} }
...@@ -723,4 +709,12 @@ void SearchBoxView::OnSpeechRecognitionStateChanged( ...@@ -723,4 +709,12 @@ void SearchBoxView::OnSpeechRecognitionStateChanged(
SchedulePaint(); SchedulePaint();
} }
void SearchBoxView::UpdateSearchIcon(bool is_google,
const SkColor& search_box_color) {
const gfx::VectorIcon& icon =
is_google ? kIcGoogleBlackIcon : kIcSearchEngineNotGoogleIcon;
search_icon_->SetImage(
gfx::CreateVectorIcon(icon, kSearchIconSize, search_box_color));
}
} // namespace app_list } // namespace app_list
...@@ -120,6 +120,9 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, ...@@ -120,6 +120,9 @@ class APP_LIST_EXPORT SearchBoxView : public views::View,
AppListModel::State current_state, AppListModel::State current_state,
AppListModel::State target_state); AppListModel::State target_state);
// Used only in the tests to get the current search icon.
views::ImageView* get_search_icon_for_test() { return search_icon_; }
private: private:
// Updates model text and selection model with current Textfield info. // Updates model text and selection model with current Textfield info.
void UpdateModel(); void UpdateModel();
...@@ -127,6 +130,9 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, ...@@ -127,6 +130,9 @@ class APP_LIST_EXPORT SearchBoxView : public views::View,
// Fires query change notification. // Fires query change notification.
void NotifyQueryChanged(); void NotifyQueryChanged();
// Updates the search icon.
void UpdateSearchIcon(bool is_google, const SkColor& search_box_color);
// Overridden from views::TextfieldController: // Overridden from views::TextfieldController:
void ContentsChanged(views::Textfield* sender, void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override; const base::string16& new_contents) override;
...@@ -157,7 +163,7 @@ class APP_LIST_EXPORT SearchBoxView : public views::View, ...@@ -157,7 +163,7 @@ class APP_LIST_EXPORT SearchBoxView : public views::View,
// Owned by views hierarchy. // Owned by views hierarchy.
views::View* content_container_; views::View* content_container_;
views::ImageView* google_icon_ = nullptr; views::ImageView* search_icon_ = nullptr;
SearchBoxImageButton* back_button_ = nullptr; SearchBoxImageButton* back_button_ = nullptr;
SearchBoxImageButton* speech_button_ = nullptr; SearchBoxImageButton* speech_button_ = nullptr;
SearchBoxImageButton* close_button_ = nullptr; SearchBoxImageButton* close_button_ = nullptr;
......
...@@ -10,10 +10,16 @@ ...@@ -10,10 +10,16 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/app_list_features.h" #include "ui/app_list/app_list_features.h"
#include "ui/app_list/test/app_list_test_view_delegate.h" #include "ui/app_list/test/app_list_test_view_delegate.h"
#include "ui/app_list/vector_icons/vector_icons.h"
#include "ui/app_list/views/app_list_view.h" #include "ui/app_list/views/app_list_view.h"
#include "ui/app_list/views/search_box_view_delegate.h" #include "ui/app_list/views/search_box_view_delegate.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/widget_test.h" #include "ui/views/test/widget_test.h"
...@@ -45,6 +51,8 @@ class KeyPressCounterView : public views::View { ...@@ -45,6 +51,8 @@ class KeyPressCounterView : public views::View {
DISALLOW_COPY_AND_ASSIGN(KeyPressCounterView); DISALLOW_COPY_AND_ASSIGN(KeyPressCounterView);
}; };
// These tests run with both FullscreenAppList enabled and disabled.
// TODO(crbug.com/743113) Unify the two test classes.
class SearchBoxViewTest : public views::test::WidgetTest, class SearchBoxViewTest : public views::test::WidgetTest,
public SearchBoxViewDelegate, public SearchBoxViewDelegate,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
...@@ -67,24 +75,26 @@ class SearchBoxViewTest : public views::test::WidgetTest, ...@@ -67,24 +75,26 @@ class SearchBoxViewTest : public views::test::WidgetTest,
gfx::NativeView parent = GetContext(); gfx::NativeView parent = GetContext();
app_list_view_ = new AppListView(&view_delegate_); app_list_view_ = new AppListView(&view_delegate_);
app_list_view_->Initialize(parent, 0, false, false); app_list_view()->Initialize(parent, 0, false, false);
widget_ = CreateTopLevelPlatformWidget(); widget_ = CreateTopLevelPlatformWidget();
view_ = new SearchBoxView(this, &view_delegate_, app_list_view_); view_.reset(new SearchBoxView(this, &view_delegate_, app_list_view()));
counter_view_ = new KeyPressCounterView(); counter_view_ = new KeyPressCounterView();
widget_->GetContentsView()->AddChildView(view_); widget_->GetContentsView()->AddChildView(view());
widget_->GetContentsView()->AddChildView(counter_view_); widget_->GetContentsView()->AddChildView(counter_view_);
view_->set_contents_view(counter_view_); view()->set_contents_view(counter_view_);
} }
void TearDown() override { void TearDown() override {
view_.reset();
app_list_view_->GetWidget()->Close(); app_list_view_->GetWidget()->Close();
widget_->CloseNow(); widget_->CloseNow();
views::test::WidgetTest::TearDown(); views::test::WidgetTest::TearDown();
} }
protected: protected:
SearchBoxView* view() { return view_; } SearchBoxView* view() { return view_.get(); }
AppListView* app_list_view() { return app_list_view_; }
bool test_with_fullscreen() { return test_with_fullscreen_; } bool test_with_fullscreen() { return test_with_fullscreen_; }
...@@ -107,11 +117,11 @@ class SearchBoxViewTest : public views::test::WidgetTest, ...@@ -107,11 +117,11 @@ class SearchBoxViewTest : public views::test::WidgetTest,
void KeyPress(ui::KeyboardCode key_code) { void KeyPress(ui::KeyboardCode key_code) {
ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE); ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
view_->search_box()->OnKeyEvent(&event); view()->search_box()->OnKeyEvent(&event);
// Emulates the input method. // Emulates the input method.
if (::isalnum(static_cast<int>(key_code))) { if (::isalnum(static_cast<int>(key_code))) {
base::char16 character = ::tolower(static_cast<int>(key_code)); base::char16 character = ::tolower(static_cast<int>(key_code));
view_->search_box()->InsertText(base::string16(1, character)); view()->search_box()->InsertText(base::string16(1, character));
} }
} }
...@@ -140,8 +150,8 @@ class SearchBoxViewTest : public views::test::WidgetTest, ...@@ -140,8 +150,8 @@ class SearchBoxViewTest : public views::test::WidgetTest,
AppListTestViewDelegate view_delegate_; AppListTestViewDelegate view_delegate_;
views::Widget* widget_; views::Widget* widget_;
SearchBoxView* view_;
AppListView* app_list_view_ = nullptr; AppListView* app_list_view_ = nullptr;
std::unique_ptr<SearchBoxView> view_;
KeyPressCounterView* counter_view_; KeyPressCounterView* counter_view_;
base::string16 last_query_; base::string16 last_query_;
int query_changed_count_ = 0; int query_changed_count_ = 0;
...@@ -151,6 +161,71 @@ class SearchBoxViewTest : public views::test::WidgetTest, ...@@ -151,6 +161,71 @@ class SearchBoxViewTest : public views::test::WidgetTest,
DISALLOW_COPY_AND_ASSIGN(SearchBoxViewTest); DISALLOW_COPY_AND_ASSIGN(SearchBoxViewTest);
}; };
class SearchBoxViewFullscreenTest : public views::test::WidgetTest,
public SearchBoxViewDelegate {
public:
SearchBoxViewFullscreenTest() {}
~SearchBoxViewFullscreenTest() override {}
// Overridden from testing::Test:
void SetUp() override {
views::test::WidgetTest::SetUp();
scoped_feature_list_.InitAndEnableFeature(
app_list::features::kEnableFullscreenAppList);
gfx::NativeView parent = GetContext();
app_list_view_ = new AppListView(&view_delegate_);
app_list_view_->Initialize(parent, 0, false, false);
widget_ = CreateTopLevelPlatformWidget();
view_.reset(new SearchBoxView(this, &view_delegate_, app_list_view()));
widget_->SetBounds(gfx::Rect(0, 0, 300, 200));
widget_->GetContentsView()->AddChildView(view());
}
void TearDown() override {
view_.reset();
app_list_view_->GetWidget()->Close();
widget_->CloseNow();
views::test::WidgetTest::TearDown();
}
protected:
SearchBoxView* view() { return view_.get(); }
AppListView* app_list_view() { return app_list_view_; }
void SetSearchEngineIsGoogle(bool is_google) {
view_delegate_.SetSearchEngineIsGoogle(is_google);
}
void KeyPress(ui::KeyboardCode key_code) {
ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
view()->search_box()->OnKeyEvent(&event);
// Emulates the input method.
if (::isalnum(static_cast<int>(key_code))) {
base::char16 character = ::tolower(static_cast<int>(key_code));
view()->search_box()->InsertText(base::string16(1, character));
}
}
private:
// Overridden from SearchBoxViewDelegate:
void QueryChanged(SearchBoxView* sender) override {}
void BackButtonPressed() override {}
void SetSearchResultSelection(bool select) override {}
base::test::ScopedFeatureList scoped_feature_list_;
AppListTestViewDelegate view_delegate_;
views::Widget* widget_;
AppListView* app_list_view_ = nullptr;
std::unique_ptr<SearchBoxView> view_;
DISALLOW_COPY_AND_ASSIGN(SearchBoxViewFullscreenTest);
};
// Instantiate the Boolean which is used to toggle the Fullscreen app list in // Instantiate the Boolean which is used to toggle the Fullscreen app list in
// the parameterized tests. // the parameterized tests.
INSTANTIATE_TEST_CASE_P(, SearchBoxViewTest, testing::Bool()); INSTANTIATE_TEST_CASE_P(, SearchBoxViewTest, testing::Bool());
...@@ -192,10 +267,7 @@ TEST_P(SearchBoxViewTest, CancelAutoLaunch) { ...@@ -192,10 +267,7 @@ TEST_P(SearchBoxViewTest, CancelAutoLaunch) {
EXPECT_EQ(base::TimeDelta(), GetAutoLaunchTimeout()); EXPECT_EQ(base::TimeDelta(), GetAutoLaunchTimeout());
} }
TEST_P(SearchBoxViewTest, CloseButtonTest) { TEST_F(SearchBoxViewFullscreenTest, CloseButtonTest) {
if (!test_with_fullscreen())
return;
KeyPress(ui::VKEY_A); KeyPress(ui::VKEY_A);
EXPECT_TRUE(view()->IsCloseButtonVisible()); EXPECT_TRUE(view()->IsCloseButtonVisible());
...@@ -203,5 +275,29 @@ TEST_P(SearchBoxViewTest, CloseButtonTest) { ...@@ -203,5 +275,29 @@ TEST_P(SearchBoxViewTest, CloseButtonTest) {
EXPECT_FALSE(view()->IsCloseButtonVisible()); EXPECT_FALSE(view()->IsCloseButtonVisible());
} }
TEST_F(SearchBoxViewFullscreenTest, SearchEngineGoogle) {
SetSearchEngineIsGoogle(true);
gfx::ImageSkia expected_icon = gfx::CreateVectorIcon(
kIcGoogleBlackIcon, kSearchIconSize, kDefaultSearchboxColor);
view()->ModelChanged();
gfx::ImageSkia actual_icon = view()->get_search_icon_for_test()->GetImage();
EXPECT_TRUE(gfx::test::AreBitmapsEqual(*expected_icon.bitmap(),
*actual_icon.bitmap()));
}
TEST_F(SearchBoxViewFullscreenTest, SearchEngineNotGoogle) {
SetSearchEngineIsGoogle(false);
gfx::ImageSkia expected_icon = gfx::CreateVectorIcon(
kIcSearchEngineNotGoogleIcon, kSearchIconSize, kDefaultSearchboxColor);
view()->ModelChanged();
gfx::ImageSkia actual_icon = view()->get_search_icon_for_test()->GetImage();
EXPECT_TRUE(gfx::test::AreBitmapsEqual(*expected_icon.bitmap(),
*actual_icon.bitmap()));
}
} // namespace test } // namespace test
} // namespace app_list } // namespace app_list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment