Commit fc7878fe authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Add tests for tabbing to desk items.

Also moves highlight related tests to a new file, and add test utils
files for shared code.

Bug: 978168
Tests: added new tests

Change-Id: Ie9e8bfea304334ca2210c08e5f5ffefa7d102e19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1689952
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683011}
parent 37ad5b38
......@@ -1872,7 +1872,10 @@ test("ash_unittests") {
"wm/overview/delayed_animation_observer_impl_unittest.cc",
"wm/overview/overview_controller_unittest.cc",
"wm/overview/overview_grid_unittest.cc",
"wm/overview/overview_highlight_controller_unittest.cc",
"wm/overview/overview_session_unittest.cc",
"wm/overview/overview_test_util.cc",
"wm/overview/overview_test_util.h",
"wm/overview/overview_window_drag_controller_unittest.cc",
"wm/overview/scoped_overview_transform_window_unittest.cc",
"wm/pip/pip_positioner_unittest.cc",
......
......@@ -76,6 +76,8 @@ class ASH_EXPORT OverviewHighlightController {
private:
class HighlightWidget;
friend class DesksOverviewHighlightControllerTest;
friend class OverviewHighlightControllerTest;
// Returns a vector of views that can be traversed via overview tabbing.
// Includes desk mini views, the new desk button and overview items.
......
This diff is collapsed.
// Copyright 2019 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/wm/overview/overview_test_util.h"
#include "ash/shell.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_item.h"
#include "ui/events/test/event_generator.h"
namespace ash {
void SendKey(ui::KeyboardCode key, int flags) {
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.PressKey(key, flags);
generator.ReleaseKey(key, flags);
}
bool HighlightOverviewWindow(const aura::Window* window) {
if (GetOverviewHighlightedWindow() == nullptr)
SendKey(ui::VKEY_TAB);
const aura::Window* start_window = GetOverviewHighlightedWindow();
if (start_window == window)
return true;
aura::Window* window_it = nullptr;
do {
SendKey(ui::VKEY_TAB);
window_it = const_cast<aura::Window*>(GetOverviewHighlightedWindow());
} while (window_it != window && window_it != start_window);
return window_it == window;
}
const aura::Window* GetOverviewHighlightedWindow() {
OverviewItem* item =
GetOverviewSession()->highlight_controller()->GetHighlightedItem();
if (!item)
return nullptr;
return item->GetWindow();
}
void ToggleOverview(OverviewSession::EnterExitOverviewType type) {
auto* overview_controller = Shell::Get()->overview_controller();
if (overview_controller->InOverviewSession())
overview_controller->EndOverview(type);
else
overview_controller->StartOverview(type);
}
OverviewSession* GetOverviewSession() {
auto* session = Shell::Get()->overview_controller()->overview_session();
DCHECK(session);
return session;
}
const std::vector<std::unique_ptr<OverviewItem>>& GetOverviewItemsForRoot(
int index) {
return GetOverviewSession()->grid_list()[index]->window_list();
}
OverviewItem* GetOverviewItemInGridWithWindow(int grid_index,
aura::Window* window) {
auto& grids = GetOverviewSession()->grid_list();
DCHECK_LT(grid_index, int{grids.size()});
return grids[grid_index]->GetOverviewItemContaining(window);
}
} // namespace ash
// Copyright 2019 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.
#ifndef ASH_WM_OVERVIEW_OVERVIEW_TEST_UTIL_H_
#define ASH_WM_OVERVIEW_OVERVIEW_TEST_UTIL_H_
#include "ash/wm/overview/overview_session.h"
#include "base/macros.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
namespace ash {
void SendKey(ui::KeyboardCode key, int flags = ui::EF_NONE);
// Highlights |window| in the active overview session by cycling through all
// windows in overview until it is found. Returns true if |window| was found,
// false otherwise.
bool HighlightOverviewWindow(const aura::Window* window);
// Gets the current highlighted window. Returns nullptr if no window is
// highlighted.
// TODO(sammiequon): Combine this with the one in
// overview_gesture_handler_unittest.cc.
const aura::Window* GetOverviewHighlightedWindow();
void ToggleOverview(OverviewSession::EnterExitOverviewType type =
OverviewSession::EnterExitOverviewType::kNormal);
OverviewSession* GetOverviewSession();
const std::vector<std::unique_ptr<OverviewItem>>& GetOverviewItemsForRoot(
int index);
// Returns the OverviewItem associated with |window| that is part of the grid
// with |grid_index| if it exists.
// TODO(sammiequon): Investiage if we can deprecate |grid_index|.
OverviewItem* GetOverviewItemInGridWithWindow(int grid_index,
aura::Window* window);
} // namespace ash
#endif // ASH_WM_OVERVIEW_OVERVIEW_TEST_UTIL_H_
......@@ -174,6 +174,7 @@ class ASH_EXPORT ScopedOverviewTransformWindow
}
private:
friend class OverviewHighlightControllerTest;
friend class OverviewSessionTest;
class LayerCachingAndFilteringObserver;
FRIEND_TEST_ALL_PREFIXES(ScopedOverviewTransformWindowWithMaskTest,
......
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