Commit 1b62135c authored by MinChen's avatar MinChen Committed by Commit Bot

Keep searchbox's corner radius during dragging the launcher.

Bug: 766904
Change-Id: I06be2da65f7072e782cd1ba30824f6a9497572eb
Reviewed-on: https://chromium-review.googlesource.com/678258Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Commit-Queue: min c <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504421}
parent 76e1d40c
......@@ -985,6 +985,63 @@ TEST_F(AppListViewFullscreenTest, TapAndClickWithinAppsGridView) {
EXPECT_EQ(AppListView::FULLSCREEN_ALL_APPS, view_->app_list_state());
}
// Tests that search box should not become a rectangle during drag.
TEST_F(AppListViewFullscreenTest, SearchBoxCornerRadiusDuringDragging) {
Initialize(0, false, false);
delegate_->GetTestModel()->PopulateApps(kInitialItems);
Show();
view_->SetState(AppListView::FULLSCREEN_ALL_APPS);
EXPECT_EQ(AppListView::FULLSCREEN_ALL_APPS, view_->app_list_state());
// Send SCROLL_START and SCROLL_UPDATE events, simulating dragging the
// launcher.
base::TimeTicks timestamp = base::TimeTicks::Now();
const gfx::Point start = view_->get_fullscreen_widget_for_test()
->GetWindowBoundsInScreen()
.top_right();
int delta_y = 0;
ui::GestureEvent start_event = ui::GestureEvent(
start.x(), start.y(), ui::EF_NONE, timestamp,
ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, delta_y));
view_->OnGestureEvent(&start_event);
// Drag down the launcher.
timestamp += base::TimeDelta::FromMilliseconds(25);
delta_y += 10;
ui::GestureEvent update_event = ui::GestureEvent(
start.x(), start.y(), ui::EF_NONE, timestamp,
ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 0, delta_y));
view_->OnGestureEvent(&update_event);
EXPECT_TRUE(IsStateShown(AppListModel::STATE_APPS));
EXPECT_EQ(kSearchBoxBorderCornerRadiusFullscreen,
search_box_view()->GetSearchBoxBorderCornerRadiusForState(
AppListModel::STATE_APPS));
// Search box should keep |kSearchBoxCornerRadiusFullscreen| corner radius
// during drag.
EXPECT_TRUE(SetAppListState(AppListModel::STATE_SEARCH_RESULTS));
EXPECT_TRUE(view_->is_in_drag());
EXPECT_EQ(kSearchBoxBorderCornerRadiusFullscreen,
search_box_view()->GetSearchBoxBorderCornerRadiusForState(
AppListModel::STATE_SEARCH_RESULTS));
// Ends to drag the launcher.
EXPECT_TRUE(SetAppListState(AppListModel::STATE_APPS));
timestamp += base::TimeDelta::FromMilliseconds(25);
ui::GestureEvent end_event =
ui::GestureEvent(start.x(), start.y() + delta_y, ui::EF_NONE, timestamp,
ui::GestureEventDetails(ui::ET_GESTURE_END));
view_->OnGestureEvent(&end_event);
// Search box should keep |kSearchBoxCornerRadiusFullscreen| corner radius
// if launcher drag finished.
EXPECT_FALSE(view_->is_in_drag());
EXPECT_EQ(kSearchBoxBorderCornerRadiusFullscreen,
search_box_view()->GetSearchBoxBorderCornerRadiusForState(
AppListModel::STATE_APPS));
}
// Tests displaying the app list and performs a standard set of checks on its
// top level views. Then closes the window.
TEST_F(AppListViewTest, DisplayTest) {
......
......@@ -708,9 +708,11 @@ void SearchBoxView::OnTabletModeChanged(bool started) {
}
int SearchBoxView::GetSearchBoxBorderCornerRadiusForState(
AppListModel::State state) {
if (state == AppListModel::STATE_SEARCH_RESULTS)
AppListModel::State state) const {
if (state == AppListModel::STATE_SEARCH_RESULTS &&
!app_list_view_->is_in_drag()) {
return kSearchBoxBorderCornerRadiusSearchResult;
}
return kSearchBoxBorderCornerRadiusFullscreen;
}
......
......@@ -137,7 +137,7 @@ class APP_LIST_EXPORT SearchBoxView : public views::View,
void OnTabletModeChanged(bool started);
// Returns background border corner radius in the given state.
static int GetSearchBoxBorderCornerRadiusForState(AppListModel::State state);
int GetSearchBoxBorderCornerRadiusForState(AppListModel::State state) const;
// Returns background color for the given state.
SkColor GetBackgroundColorForState(AppListModel::State state) const;
......
......@@ -447,8 +447,8 @@ void SearchResultPageView::OnAnimationUpdated(double progress,
color,
gfx::Tween::LinearIntValueBetween(
progress,
SearchBoxView::GetSearchBoxBorderCornerRadiusForState(from_state),
SearchBoxView::GetSearchBoxBorderCornerRadiusForState(to_state))));
search_box->GetSearchBoxBorderCornerRadiusForState(from_state),
search_box->GetSearchBoxBorderCornerRadiusForState(to_state))));
}
gfx::Rect onscreen_bounds(
......
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