Commit b4b210ad authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Use SystemTrayTestApi in a11y browser tests.

This CL restores disabled TrayAccessibilityTest browser tests by using
SystemTrayTestApi mojo interface.

Although now the style of the test is Mash compliant, it still doesn't
work with Mash because some a11y features are not yet ported to Mash.

TEST=browser_tests
BUG=850014

Change-Id: I25bc3ec4b7409eb97632e9b14fc91aedf8fed178
Reviewed-on: https://chromium-review.googlesource.com/c/1309554Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605227}
parent 17361802
......@@ -13,6 +13,11 @@ enum ViewID {
// Ash IDs start above the range used in Chrome (c/b/ui/view_ids.h).
VIEW_ID_ASH_START = 10000,
// Row for auto click feature in accessibility detailed view.
VIEW_ID_ACCESSIBILITY_AUTOCLICK,
// Icon that indicates auto click is enabled.
VIEW_ID_ACCESSIBILITY_AUTOCLICK_ENABLED,
// Accessibility feature pod button in main view.
VIEW_ID_ACCESSIBILITY_TRAY_ITEM,
VIEW_ID_BLUETOOTH_DEFAULT_VIEW,
// System tray casting row elements.
......
......@@ -9,7 +9,7 @@ import "mojo/public/mojom/base/string16.mojom";
// Top-level items in the system tray bubble.
// TODO(jamescook): Consolidate with SystemTrayItem::UmaType.
enum TrayItem {
kEnterprise,
kAccessibility,
kNetwork,
};
......@@ -36,7 +36,11 @@ interface SystemTrayTestApi {
ShowDetailedView(TrayItem item) => ();
// Returns true if the view exists in the bubble and is visible.
IsBubbleViewVisible(int32 view_id) => (bool visible);
// If |open_tray| is true, it also opens system tray bubble.
IsBubbleViewVisible(int32 view_id, bool open_tray) => (bool visible);
// Clicks the view |view_id|.
ClickBubbleView(int32 view_id) => ();
// Returns the tooltip for a bubble view, or the empty string if the view
// does not exist.
......
......@@ -5,6 +5,7 @@
#include "ash/system/accessibility/accessibility_feature_pod_controller.h"
#include "ash/accessibility/accessibility_delegate.h"
#include "ash/public/cpp/ash_view_ids.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
......@@ -24,6 +25,7 @@ AccessibilityFeaturePodController::~AccessibilityFeaturePodController() =
FeaturePodButton* AccessibilityFeaturePodController::CreateButton() {
auto* button = new FeaturePodButton(this);
button->set_id(ash::VIEW_ID_ACCESSIBILITY_TRAY_ITEM);
button->SetLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY));
button->SetVectorIcon(kUnifiedMenuAccessibilityIcon);
......@@ -35,6 +37,7 @@ FeaturePodButton* AccessibilityFeaturePodController::CreateButton() {
AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate();
LoginStatus login_status = Shell::Get()->session_controller()->login_status();
button->SetVisible(login_status == LoginStatus::NOT_LOGGED_IN ||
login_status == LoginStatus::LOCKED ||
delegate->ShouldShowAccessibilityMenu());
return button;
}
......
......@@ -266,6 +266,9 @@ void AccessibilityDetailedView::AppendAccessibilityList() {
kSystemMenuAccessibilityAutoClickIcon,
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_AUTOCLICK),
autoclick_enabled_);
autoclick_view_->set_id(ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK);
autoclick_view_->right_view()->set_id(
ash::VIEW_ID_ACCESSIBILITY_AUTOCLICK_ENABLED);
virtual_keyboard_enabled_ = controller->IsVirtualKeyboardEnabled();
virtual_keyboard_view_ = AddScrollListCheckableItem(
......
......@@ -96,6 +96,7 @@ class HoverHighlightView : public ActionableView {
views::Label* text_label() { return text_label_; }
views::Label* sub_text_label() { return sub_text_label_; }
views::ImageView* left_icon() { return left_icon_; }
views::View* right_view() { return right_view_; }
protected:
// Override from Button to also set the tooltip for all child elements.
......
......@@ -79,20 +79,20 @@ void SystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) {
void SystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) {
SystemTrayItem* tray_item;
SystemTrayItem* tray_item = nullptr;
switch (item) {
case mojom::TrayItem::kEnterprise:
tray_item = tray_->tray_enterprise_;
break;
case mojom::TrayItem::kNetwork:
tray_item = tray_->tray_network_;
break;
default:
break;
}
tray_->ShowDetailedView(tray_item, 0 /* delay */, BUBBLE_CREATE_NEW);
std::move(cb).Run();
}
void SystemTrayTestApi::IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) {
views::View* view = GetBubbleView(view_id);
std::move(cb).Run(view && view->visible());
......
......@@ -50,7 +50,9 @@ class SystemTrayTestApi : public mojom::SystemTrayTestApi {
void ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) override;
void IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) override;
void ClickBubbleView(int32_t view_id, ClickBubbleViewCallback cb) override {}
void GetBubbleViewTooltip(int view_id,
GetBubbleViewTooltipCallback cb) override;
void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override;
......
......@@ -12,9 +12,11 @@
#include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/controls/label.h"
#include "ui/views/view.h"
......@@ -63,15 +65,12 @@ void UnifiedSystemTrayTestApi::CloseBubble(CloseBubbleCallback cb) {
void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) {
tray_->ShowBubble(false /* show_by_click */);
switch (item) {
case mojom::TrayItem::kEnterprise:
// TODO(tetsui): Remove this from .mojom, because both SystemTray and
// UnifiedSystemTray do not have enterprise detailed view, and this is not
// used from anywhere.
NOTREACHED();
case mojom::TrayItem::kAccessibility:
tray_->bubble_->controller_->ShowAccessibilityDetailedView();
break;
case mojom::TrayItem::kNetwork:
tray_->ShowBubble(false /* show_by_click */);
tray_->bubble_->controller_->ShowNetworkDetailedView(true /* force */);
break;
}
......@@ -80,11 +79,28 @@ void UnifiedSystemTrayTestApi::ShowDetailedView(mojom::TrayItem item,
void UnifiedSystemTrayTestApi::IsBubbleViewVisible(
int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) {
if (open_tray)
tray_->ShowBubble(false /* show_by_click */);
views::View* view = GetBubbleView(view_id);
std::move(cb).Run(view && view->visible());
}
void UnifiedSystemTrayTestApi::ClickBubbleView(int32_t view_id,
ClickBubbleViewCallback cb) {
views::View* view = GetBubbleView(view_id);
if (view && view->visible()) {
gfx::Point cursor_location(1, 1);
views::View::ConvertPointToScreen(view, &cursor_location);
ui::test::EventGenerator generator(view->GetWidget()->GetNativeWindow());
generator.MoveMouseTo(cursor_location);
generator.ClickLeftButton();
}
std::move(cb).Run();
}
void UnifiedSystemTrayTestApi::GetBubbleViewTooltip(
int view_id,
GetBubbleViewTooltipCallback cb) {
......
......@@ -41,7 +41,9 @@ class UnifiedSystemTrayTestApi : public mojom::SystemTrayTestApi {
void ShowDetailedView(mojom::TrayItem item,
ShowDetailedViewCallback cb) override;
void IsBubbleViewVisible(int view_id,
bool open_tray,
IsBubbleViewVisibleCallback cb) override;
void ClickBubbleView(int32_t view_id, ClickBubbleViewCallback cb) override;
void GetBubbleViewTooltip(int view_id,
GetBubbleViewTooltipCallback cb) override;
void GetBubbleLabelText(int view_id, GetBubbleLabelTextCallback cb) override;
......
......@@ -75,13 +75,12 @@ IN_PROC_BROWSER_TEST_F(SystemTrayClientEnterpriseTest, TrayEnterprise) {
->GetConnector()
->BindInterface(ash::mojom::kServiceName, &tray_test_api);
// Open the system tray menu.
ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api.get());
wait_for.ShowBubble();
// Managed devices show an item in the menu.
bool view_visible = false;
wait_for.IsBubbleViewVisible(ash::VIEW_ID_TRAY_ENTERPRISE, &view_visible);
wait_for.IsBubbleViewVisible(ash::VIEW_ID_TRAY_ENTERPRISE,
true /* open_tray */, &view_visible);
EXPECT_TRUE(view_visible);
}
......
......@@ -56,7 +56,7 @@ class SystemTrayTrayCastMediaRouterChromeOSTest : public InProcessBrowserTest {
bool IsViewDrawn(int view_id) {
ash::mojom::SystemTrayTestApiAsyncWaiter wait_for(tray_test_api_.get());
bool visible = false;
wait_for.IsBubbleViewVisible(view_id, &visible);
wait_for.IsBubbleViewVisible(view_id, false /* open_tray */, &visible);
return visible;
}
......
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