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

Fix status area focus test for UnifiedSystemTray.

In the unit test, focusing in status area widget was tested using
NotificationTray button and SystemTray button. As they are
consolidated in UnifiedSystemTray, the test did not work with the flag
enabled. This CL fixes the test to use IME tray button so it keeps
working with UnifiedSystemTray.

TEST=StatusAreaWidgetFocusTest.FocusOutObserver
(--enable-features=SystemTrayUnified)
BUG=847104

Change-Id: I8d8d3f274153daeb66ebc594d23b7ce4787a2cac
Reviewed-on: https://chromium-review.googlesource.com/1088331Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564923}
parent eb0f6479
......@@ -140,6 +140,10 @@ class StatusAreaWidgetFocusTest : public AshTestBase {
// Tests that tab traversal through status area widget in non-active session
// could properly send FocusOut event.
TEST_F(StatusAreaWidgetFocusTest, FocusOutObserver) {
// This is old SystemTray version.
if (features::IsSystemTrayUnifiedEnabled())
return;
// Set session state to LOCKED.
SessionController* session = Shell::Get()->session_controller();
ASSERT_TRUE(session->IsActiveUserSessionStarted());
......@@ -158,7 +162,7 @@ TEST_F(StatusAreaWidgetFocusTest, FocusOutObserver) {
// Needed because NotificationTray updates its initial visibility
// asynchronously.
RunAllPendingInMessageLoop();
base::RunLoop().RunUntilIdle();
// Default trays are visible.
ASSERT_FALSE(status->overview_button_tray()->visible());
......@@ -194,6 +198,70 @@ TEST_F(StatusAreaWidgetFocusTest, FocusOutObserver) {
EXPECT_EQ(1, test_observer_->reverse_focus_out_count());
}
// Tests that tab traversal through status area widget in non-active session
// could properly send FocusOut event.
TEST_F(StatusAreaWidgetFocusTest, FocusOutObserverUnified) {
// This is UnifiedSystemTray version.
if (!features::IsSystemTrayUnifiedEnabled())
return;
// Set session state to LOCKED.
SessionController* session = Shell::Get()->session_controller();
ASSERT_TRUE(session->IsActiveUserSessionStarted());
TestSessionControllerClient* client = GetSessionControllerClient();
client->SetSessionState(SessionState::LOCKED);
ASSERT_TRUE(session->IsScreenLocked());
StatusAreaWidget* status = StatusAreaWidgetTestHelper::GetStatusAreaWidget();
// Default trays are constructed.
ASSERT_TRUE(status->overview_button_tray());
ASSERT_TRUE(status->unified_system_tray());
ASSERT_TRUE(status->logout_button_tray_for_testing());
ASSERT_TRUE(status->ime_menu_tray());
ASSERT_TRUE(status->virtual_keyboard_tray_for_testing());
// Needed because NotificationTray updates its initial visibility
// asynchronously.
base::RunLoop().RunUntilIdle();
// Default trays are visible.
ASSERT_FALSE(status->overview_button_tray()->visible());
ASSERT_TRUE(status->unified_system_tray()->visible());
ASSERT_FALSE(status->logout_button_tray_for_testing()->visible());
ASSERT_FALSE(status->ime_menu_tray()->visible());
ASSERT_FALSE(status->virtual_keyboard_tray_for_testing()->visible());
// In Unified, we don't have notification tray, so ImeMenuTray is used for
// tab testing.
status->ime_menu_tray()->OnIMEMenuActivationChanged(true);
ASSERT_TRUE(status->ime_menu_tray()->visible());
// Set focus to status area widget, which will be be system tray.
ASSERT_TRUE(Shell::Get()->focus_cycler()->FocusWidget(status));
views::FocusManager* focus_manager = status->GetFocusManager();
EXPECT_EQ(status->unified_system_tray(), focus_manager->GetFocusedView());
// A tab key event will move focus to notification tray.
GenerateTabEvent(false);
EXPECT_EQ(status->ime_menu_tray(), focus_manager->GetFocusedView());
EXPECT_EQ(0, test_observer_->focus_out_count());
EXPECT_EQ(0, test_observer_->reverse_focus_out_count());
// Another tab key event will send FocusOut event, since we are not handling
// this event, focus will still be moved to system tray.
GenerateTabEvent(false);
EXPECT_EQ(status->unified_system_tray(), focus_manager->GetFocusedView());
EXPECT_EQ(1, test_observer_->focus_out_count());
EXPECT_EQ(0, test_observer_->reverse_focus_out_count());
// A reverse tab key event will send reverse FocusOut event, since we are not
// handling this event, focus will still be moved to notification tray.
GenerateTabEvent(true);
EXPECT_EQ(status->ime_menu_tray(), focus_manager->GetFocusedView());
EXPECT_EQ(1, test_observer_->focus_out_count());
EXPECT_EQ(1, test_observer_->reverse_focus_out_count());
}
class StatusAreaWidgetPaletteTest : public AshTestBase {
public:
StatusAreaWidgetPaletteTest() = default;
......
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