Commit e94b540b authored by rsadam's avatar rsadam Committed by Commit bot

Moves smart deploy UI into the IME tray.

BUG=447642, 443766
TEST=TrayIMETest.PerformActionOnDetailedView, TrayIMETest.HidesOnA11yEnabled, TrayIMETest.HiddenWithNoIMEs

Review URL: https://codereview.chromium.org/843603004

Cr-Commit-Position: refs/heads/master@{#311394}
parent 35698674
...@@ -347,8 +347,8 @@ ...@@ -347,8 +347,8 @@
'system/date/tray_date.cc', 'system/date/tray_date.cc',
'system/date/tray_date.h', 'system/date/tray_date.h',
'system/ime/ime_observer.h', 'system/ime/ime_observer.h',
'system/ime/tray_ime.cc', 'system/ime/tray_ime_chromeos.cc',
'system/ime/tray_ime.h', 'system/ime/tray_ime_chromeos.h',
'system/keyboard_brightness/keyboard_brightness_control_delegate.h', 'system/keyboard_brightness/keyboard_brightness_control_delegate.h',
'system/locale/locale_notification_controller.cc', 'system/locale/locale_notification_controller.cc',
'system/locale/locale_notification_controller.h', 'system/locale/locale_notification_controller.h',
...@@ -806,6 +806,7 @@ ...@@ -806,6 +806,7 @@
'system/chromeos/session/tray_session_length_limit_unittest.cc', 'system/chromeos/session/tray_session_length_limit_unittest.cc',
'system/chromeos/supervised/tray_supervised_user_unittest.cc', 'system/chromeos/supervised/tray_supervised_user_unittest.cc',
'system/chromeos/tray_display_unittest.cc', 'system/chromeos/tray_display_unittest.cc',
'system/ime/tray_ime_chromeos_unittest.cc',
'system/date/date_view_unittest.cc', 'system/date/date_view_unittest.cc',
'system/overview/overview_button_tray_unittest.cc', 'system/overview/overview_button_tray_unittest.cc',
'system/tray/media_security/multi_profile_media_tray_item_unittest.cc', 'system/tray/media_security/multi_profile_media_tray_item_unittest.cc',
......
...@@ -346,6 +346,12 @@ Press Shift + Alt to switch. ...@@ -346,6 +346,12 @@ Press Shift + Alt to switch.
<message name="IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED" desc="The text shown in the tray menu when the virtual keyboard is enabled."> <message name="IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED" desc="The text shown in the tray menu when the virtual keyboard is enabled.">
On-screen keyboard enabled On-screen keyboard enabled
</message> </message>
<message name="IDS_ASH_STATUS_TRAY_ENABLE_KEYBOARD" desc="A button label in the tray menu to enable the keyboard.">
Enable on-screen keyboard
</message>
<message name="IDS_ASH_STATUS_TRAY_DISABLE_KEYBOARD" desc="A button label in the tray menu to disable the keyboard.">
Disable on-screen keyboard
</message>
<message name="IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME" desc="The accessible text for virtual keyboard icon in status tray."> <message name="IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME" desc="The accessible text for virtual keyboard icon in status tray.">
Show on-screen keyboard Show on-screen keyboard
</message> </message>
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_SYSTEM_IME_TRAY_IME_H_ #ifndef ASH_SYSTEM_IME_TRAY_IME_CHROMEOS_H_
#define ASH_SYSTEM_IME_TRAY_IME_H_ #define ASH_SYSTEM_IME_TRAY_IME_CHROMEOS_H_
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h"
#include "ash/system/ime/ime_observer.h" #include "ash/system/ime/ime_observer.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray_accessibility.h"
namespace views { namespace views {
class Label; class Label;
...@@ -23,14 +26,33 @@ class IMENotificationView; ...@@ -23,14 +26,33 @@ class IMENotificationView;
class TrayItemView; class TrayItemView;
class TrayIME : public SystemTrayItem, class ASH_EXPORT TrayIME : public SystemTrayItem,
public IMEObserver { public IMEObserver,
public AccessibilityObserver,
public VirtualKeyboardObserver {
public: public:
explicit TrayIME(SystemTray* system_tray); explicit TrayIME(SystemTray* system_tray);
~TrayIME() override; ~TrayIME() override;
// Overridden from VirtualKeyboardObserver.
void OnKeyboardSuppressionChanged(bool suppressed) override;
// Overridden from AccessibilityObserver:
void OnAccessibilityModeChanged(
ui::AccessibilityNotificationVisibility notify) override;
private: private:
friend class TrayIMETest;
// Repopulates the DefaultView and DetailedView.
void Update();
// Updates the System Tray label.
void UpdateTrayLabel(const IMEInfo& info, size_t count); void UpdateTrayLabel(const IMEInfo& info, size_t count);
// Returns whether the virtual keyboard toggle should be shown in the
// detailed view.
bool ShouldShowKeyboardToggle();
// Returns the appropriate label for the detailed view.
base::string16 GetDefaultViewLabel(bool show_ime_label);
// Overridden from SystemTrayItem. // Overridden from SystemTrayItem.
views::View* CreateTrayView(user::LoginStatus status) override; views::View* CreateTrayView(user::LoginStatus status) override;
...@@ -45,13 +67,22 @@ class TrayIME : public SystemTrayItem, ...@@ -45,13 +67,22 @@ class TrayIME : public SystemTrayItem,
// Overridden from IMEObserver. // Overridden from IMEObserver.
void OnIMERefresh() override; void OnIMERefresh() override;
// Whether the default view should be shown.
bool ShouldDefaultViewBeVisible();
TrayItemView* tray_label_; TrayItemView* tray_label_;
tray::IMEDefaultView* default_; tray::IMEDefaultView* default_;
tray::IMEDetailedView* detailed_; tray::IMEDetailedView* detailed_;
// Whether the virtual keyboard is suppressed.
bool keyboard_suppressed_;
// Cached IME info.
IMEInfoList ime_list_;
IMEInfo current_ime_;
IMEPropertyInfoList property_list_;
DISALLOW_COPY_AND_ASSIGN(TrayIME); DISALLOW_COPY_AND_ASSIGN(TrayIME);
}; };
} // namespace ash } // namespace ash
#endif // ASH_SYSTEM_IME_TRAY_IME_H_ #endif // ASH_SYSTEM_IME_TRAY_IME_CHROMEOS_H_
// Copyright 2014 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/system/ime/tray_ime_chromeos.h"
#include "ash/accessibility_delegate.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h"
#include "ash/test/virtual_keyboard_test_helper.h"
#include "base/command_line.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_util.h"
namespace ash {
class TrayIMETest : public test::AshTestBase {
public:
TrayIMETest() {}
virtual ~TrayIMETest() {}
TrayIME* tray() { return tray_.get(); }
views::View* default_view() { return default_view_.get(); }
views::View* detailed_view() { return detailed_view_.get(); }
// Sets up a TrayIME and its default view.
void SetUpForStatusAreaWidget(StatusAreaWidget* status_area_widget);
// Mocks enabling the a11y virtual keyboard since the actual a11y manager
// is not created in ash tests.
void SetAccessibilityKeyboardEnabled(bool enabled);
// Resets |tray_| and |default_view_| so that all components of
// TrayIME have been cleared. Tests may then call
// SetUpForStatusAreaWidget in order to initialize the components.
void TearDownViews();
// Sets the current number of active IMEs.
void SetIMELength(int length);
// Returns the view in the detailed views scroll content at the provided
// index.
views::View* GetScrollChildView(int index);
// test::AshTestBase:
virtual void SetUp() override;
virtual void TearDown() override;
private:
scoped_ptr<TrayIME> tray_;
scoped_ptr<views::View> default_view_;
scoped_ptr<views::View> detailed_view_;
};
void TrayIMETest::SetUpForStatusAreaWidget(
StatusAreaWidget* status_area_widget) {
tray_.reset(new TrayIME(status_area_widget->system_tray()));
default_view_.reset(tray_->CreateDefaultView(
StatusAreaWidgetTestHelper::GetUserLoginStatus()));
detailed_view_.reset(tray_->CreateDetailedView(
StatusAreaWidgetTestHelper::GetUserLoginStatus()));
}
void TrayIMETest::SetAccessibilityKeyboardEnabled(bool enabled) {
Shell::GetInstance()->accessibility_delegate()->SetVirtualKeyboardEnabled(
enabled);
keyboard::SetAccessibilityKeyboardEnabled(enabled);
ui::AccessibilityNotificationVisibility notification =
enabled ? ui::AccessibilityNotificationVisibility::A11Y_NOTIFICATION_SHOW
: ui::AccessibilityNotificationVisibility::A11Y_NOTIFICATION_NONE;
Shell::GetInstance()->system_tray_notifier()->NotifyAccessibilityModeChanged(
notification);
}
void TrayIMETest::TearDownViews() {
tray_.reset();
default_view_.reset();
detailed_view_.reset();
}
void TrayIMETest::SetIMELength(int length) {
tray_->ime_list_.clear();
IMEInfo ime;
for (int i = 0; i < length; i++) {
tray_->ime_list_.push_back(ime);
}
tray_->Update();
}
views::View* TrayIMETest::GetScrollChildView(int index) {
TrayDetailsView* details = static_cast<TrayDetailsView*>(detailed_view());
views::View* content = details->scroll_content();
EXPECT_TRUE(content);
EXPECT_GT(content->child_count(), index);
return content->child_at(index);
}
void TrayIMETest::SetUp() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
keyboard::switches::kEnableAutoVirtualKeyboard);
test::AshTestBase::SetUp();
SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
}
void TrayIMETest::TearDown() {
SetAccessibilityKeyboardEnabled(false);
TearDownViews();
test::AshTestBase::TearDown();
}
// Tests that if the keyboard is not suppressed the default view is hidden
// if less than 2 IMEs are present.
TEST_F(TrayIMETest, HiddenWithNoIMEs) {
SetIMELength(0);
EXPECT_FALSE(default_view()->visible());
SetIMELength(1);
EXPECT_FALSE(default_view()->visible());
SetIMELength(2);
EXPECT_TRUE(default_view()->visible());
}
// Tests that if no IMEs are present the default view is hidden when a11y is
// enabled.
TEST_F(TrayIMETest, HidesOnA11yEnabled) {
SetIMELength(0);
test::VirtualKeyboardTestHelper::SuppressKeyboard();
EXPECT_TRUE(default_view()->visible());
// Enable a11y keyboard.
SetAccessibilityKeyboardEnabled(true);
EXPECT_FALSE(default_view()->visible());
// Disable the a11y keyboard.
SetAccessibilityKeyboardEnabled(false);
EXPECT_TRUE(default_view()->visible());
}
// Tests that clicking on the keyboard toggle causes the virtual keyboard
// to toggle between enabled and disabled.
TEST_F(TrayIMETest, PerformActionOnDetailedView) {
SetIMELength(0);
test::VirtualKeyboardTestHelper::SuppressKeyboard();
EXPECT_FALSE(keyboard::IsKeyboardEnabled());
views::View* toggle = GetScrollChildView(0);
ui::GestureEvent tap(0, 0, 0, base::TimeDelta(),
ui::GestureEventDetails(ui::ET_GESTURE_TAP));
// Enable the keyboard.
toggle->OnGestureEvent(&tap);
EXPECT_TRUE(keyboard::IsKeyboardEnabled());
EXPECT_TRUE(default_view()->visible());
// With no IMEs the toggle should be the first child.
toggle = GetScrollChildView(0);
// Clicking again should disable the keyboard.
tap = ui::GestureEvent(0, 0, 0, base::TimeDelta(),
ui::GestureEventDetails(ui::ET_GESTURE_TAP));
toggle->OnGestureEvent(&tap);
EXPECT_FALSE(keyboard::IsKeyboardEnabled());
EXPECT_TRUE(default_view()->visible());
}
} // namespace ash
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ash/system/audio/tray_audio.h" #include "ash/system/audio/tray_audio.h"
#include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/date/tray_date.h" #include "ash/system/date/tray_date.h"
#include "ash/system/ime/tray_ime.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/system_tray_item.h"
...@@ -59,6 +58,7 @@ ...@@ -59,6 +58,7 @@
#include "ash/system/chromeos/tray_caps_lock.h" #include "ash/system/chromeos/tray_caps_lock.h"
#include "ash/system/chromeos/tray_display.h" #include "ash/system/chromeos/tray_display.h"
#include "ash/system/chromeos/tray_tracing.h" #include "ash/system/chromeos/tray_tracing.h"
#include "ash/system/ime/tray_ime_chromeos.h"
#include "ash/system/tray/media_security/multi_profile_media_tray_item.h" #include "ash/system/tray/media_security/multi_profile_media_tray_item.h"
#include "ui/message_center/message_center.h" #include "ui/message_center/message_center.h"
#elif defined(OS_WIN) #elif defined(OS_WIN)
...@@ -201,7 +201,6 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { ...@@ -201,7 +201,6 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
AddTrayItem(new TrayUpdate(this)); AddTrayItem(new TrayUpdate(this));
AddTrayItem(tray_date_); AddTrayItem(tray_date_);
#elif defined(OS_LINUX) #elif defined(OS_LINUX)
AddTrayItem(new TrayIME(this));
AddTrayItem(tray_accessibility_); AddTrayItem(tray_accessibility_);
AddTrayItem(new TrayBluetooth(this)); AddTrayItem(new TrayBluetooth(this));
AddTrayItem(new TrayUpdate(this)); AddTrayItem(new TrayUpdate(this));
......
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