Commit aeb94ecd authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Extend test api to return screen bounds of icons

Bug: 1058135
Change-Id: Id07d08176af1d0ca8641e651e19f0d0dc389045b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2118225Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753461}
parent 6d8f6b7a
......@@ -205,6 +205,7 @@ component("cpp") {
"shelf_prefs.h",
"shelf_types.cc",
"shelf_types.h",
"shelf_ui_info.cc",
"shelf_ui_info.h",
"shell_window_ids.cc",
"shell_window_ids.h",
......
// Copyright (c) 2020 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.
#include "ash/public/cpp/shelf_ui_info.h"
namespace ash {
ScrollableShelfInfo::ScrollableShelfInfo() = default;
ScrollableShelfInfo::ScrollableShelfInfo(const ScrollableShelfInfo& rhs) =
default;
ScrollableShelfInfo& ScrollableShelfInfo::operator=(
const ScrollableShelfInfo& rhs) = default;
ScrollableShelfInfo::~ScrollableShelfInfo() = default;
} // namespace ash
......@@ -13,6 +13,11 @@
namespace ash {
struct ASH_PUBLIC_EXPORT ScrollableShelfInfo {
ScrollableShelfInfo();
ScrollableShelfInfo(const ScrollableShelfInfo& info);
ScrollableShelfInfo& operator=(const ScrollableShelfInfo& info);
~ScrollableShelfInfo();
// Current offset on the main axis.
float main_axis_offset = 0.f;
......@@ -33,6 +38,9 @@ struct ASH_PUBLIC_EXPORT ScrollableShelfInfo {
// Indicates whether scrollable shelf is in overflow mode.
bool is_overflow = false;
// Screen bounds of visible shelf icons.
std::vector<gfx::Rect> icons_bounds_in_screen;
};
struct ASH_PUBLIC_EXPORT ShelfState {
......
......@@ -77,6 +77,13 @@ ScrollableShelfInfo ShelfTestApi::GetScrollableShelfInfoForState(
info.is_overflow = (scrollable_shelf_view->layout_strategy_ !=
ScrollableShelfView::kNotShowArrowButtons);
const ShelfView* const shelf_view = scrollable_shelf_view->shelf_view_;
for (int i = shelf_view->first_visible_index();
i <= shelf_view->last_visible_index(); ++i) {
info.icons_bounds_in_screen.push_back(
shelf_view->view_model()->view_at(i)->GetBoundsInScreen());
}
// Calculates the target offset only when |scroll_distance| is specified.
if (state.scroll_distance != 0.f) {
const float target_offset =
......
......@@ -267,6 +267,7 @@ class ASH_EXPORT ShelfView : public views::AccessiblePaneView,
}
ShelfWidget* shelf_widget() const { return shelf_->shelf_widget(); }
views::ViewModel* view_model() { return view_model_.get(); }
const views::ViewModel* view_model() const { return view_model_.get(); }
bool dragged_off_shelf() const { return dragged_off_shelf_; }
ShelfID drag_and_drop_shelf_id() const { return drag_and_drop_shelf_id_; }
......
......@@ -545,6 +545,14 @@ api::autotest_private::Bounds ToBoundsDictionary(const gfx::Rect& bounds) {
return result;
}
std::vector<api::autotest_private::Bounds> ToBoundsDictionaryList(
const std::vector<gfx::Rect>& items_bounds) {
std::vector<api::autotest_private::Bounds> bounds_list;
for (const gfx::Rect& bounds : items_bounds)
bounds_list.push_back(ToBoundsDictionary(bounds));
return bounds_list;
}
api::autotest_private::Location ToLocationDictionary(const gfx::Point& point) {
api::autotest_private::Location result;
result.x = point.x();
......@@ -4149,6 +4157,8 @@ AutotestPrivateGetShelfUIInfoForStateFunction::Run() {
ToBoundsDictionary(fetched_info.right_arrow_bounds);
scrollable_shelf_ui_info.is_animating = fetched_info.is_animating;
scrollable_shelf_ui_info.is_overflow = fetched_info.is_overflow;
scrollable_shelf_ui_info.icons_bounds_in_screen =
ToBoundsDictionaryList(fetched_info.icons_bounds_in_screen);
if (state.scroll_distance) {
scrollable_shelf_ui_info.target_main_axis_offset =
......
......@@ -458,6 +458,7 @@ namespace autotestPrivate {
Bounds rightArrowBounds;
boolean isAnimating;
boolean isOverflow;
Bounds[] iconsBoundsInScreen;
};
// Mapped to HotseatSwipeDescriptor in ash/public/cpp/shelf_ui_info.h.
......
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