Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ash/common/system/ime/tray_ime_chromeos_unittest.cc

Issue 2652793003: Add login screen locale and input method device policies (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/ime/tray_ime_chromeos.h" 5 #include "ash/common/system/ime/tray_ime_chromeos.h"
6 6
7 #include "ash/common/accessibility_delegate.h" 7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/accessibility_types.h" 8 #include "ash/common/accessibility_types.h"
9 #include "ash/common/system/tray/system_tray_notifier.h" 9 #include "ash/common/system/tray/system_tray_notifier.h"
10 #include "ash/common/system/tray/tray_details_view.h" 10 #include "ash/common/system/tray/tray_details_view.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/strings/utf_string_conversions.h"
14 #include "ui/events/devices/device_data_manager.h" 15 #include "ui/events/devices/device_data_manager.h"
15 #include "ui/keyboard/keyboard_util.h" 16 #include "ui/keyboard/keyboard_util.h"
16 17
17 namespace ash { 18 namespace ash {
18 19
19 class TrayIMETest : public test::AshTestBase { 20 class TrayIMETest : public test::AshTestBase {
20 public: 21 public:
21 TrayIMETest() {} 22 TrayIMETest() {}
22 ~TrayIMETest() override {} 23 ~TrayIMETest() override {}
23 24
24 TrayIME* tray() { return tray_.get(); } 25 TrayIME* tray() { return tray_.get(); }
25 26
26 views::View* default_view() { return default_view_.get(); } 27 views::View* default_view() { return default_view_.get(); }
27 28
28 views::View* detailed_view() { return detailed_view_.get(); } 29 views::View* detailed_view() { return detailed_view_.get(); }
29 30
30 // Mocks enabling the a11y virtual keyboard since the actual a11y manager 31 // Mocks enabling the a11y virtual keyboard since the actual a11y manager
31 // is not created in ash tests. 32 // is not created in ash tests.
32 void SetAccessibilityKeyboardEnabled(bool enabled); 33 void SetAccessibilityKeyboardEnabled(bool enabled);
33 34
34 // Sets the current number of active IMEs. 35 // Sets the current number of active IMEs.
35 void SetIMELength(int length); 36 void SetIMELength(int length);
36 37
38 // Sets the managed IMEs tooltip message (and thus also if IMEs are managed =
39 // non-empty or not = empty)
40 void SetManagedMessage(base::string16 managed_message);
41
37 // Returns the view in the detailed views scroll content at the provided 42 // Returns the view in the detailed views scroll content at the provided
38 // index. 43 // index.
39 views::View* GetScrollChildView(int index); 44 views::View* GetScrollChildView(int index);
40 45
41 void SuppressKeyboard(); 46 void SuppressKeyboard();
42 void RestoreKeyboard(); 47 void RestoreKeyboard();
43 48
44 // test::AshTestBase: 49 // test::AshTestBase:
45 void SetUp() override; 50 void SetUp() override;
46 void TearDown() override; 51 void TearDown() override;
(...skipping 21 matching lines...) Expand all
68 73
69 void TrayIMETest::SetIMELength(int length) { 74 void TrayIMETest::SetIMELength(int length) {
70 tray_->ime_list_.clear(); 75 tray_->ime_list_.clear();
71 IMEInfo ime; 76 IMEInfo ime;
72 for (int i = 0; i < length; i++) { 77 for (int i = 0; i < length; i++) {
73 tray_->ime_list_.push_back(ime); 78 tray_->ime_list_.push_back(ime);
74 } 79 }
75 tray_->Update(); 80 tray_->Update();
76 } 81 }
77 82
83 void TrayIMETest::SetManagedMessage(base::string16 managed_message) {
84 tray_->ime_managed_message_ = managed_message;
85 tray_->Update();
86 }
87
78 views::View* TrayIMETest::GetScrollChildView(int index) { 88 views::View* TrayIMETest::GetScrollChildView(int index) {
79 TrayDetailsView* details = static_cast<TrayDetailsView*>(detailed_view()); 89 TrayDetailsView* details = static_cast<TrayDetailsView*>(detailed_view());
80 views::View* content = details->scroll_content(); 90 views::View* content = details->scroll_content();
81 EXPECT_TRUE(content); 91 EXPECT_TRUE(content);
82 EXPECT_GT(content->child_count(), index); 92 EXPECT_GT(content->child_count(), index);
83 return content->child_at(index); 93 return content->child_at(index);
84 } 94 }
85 95
86 void TrayIMETest::SuppressKeyboard() { 96 void TrayIMETest::SuppressKeyboard() {
87 DCHECK(!keyboard_suppressed_); 97 DCHECK(!keyboard_suppressed_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 SetAccessibilityKeyboardEnabled(false); 136 SetAccessibilityKeyboardEnabled(false);
127 tray_.reset(); 137 tray_.reset();
128 default_view_.reset(); 138 default_view_.reset();
129 detailed_view_.reset(); 139 detailed_view_.reset();
130 test::AshTestBase::TearDown(); 140 test::AshTestBase::TearDown();
131 } 141 }
132 142
133 // Tests that if the keyboard is not suppressed the default view is hidden 143 // Tests that if the keyboard is not suppressed the default view is hidden
134 // if less than 2 IMEs are present. 144 // if less than 2 IMEs are present.
135 TEST_F(TrayIMETest, HiddenWithNoIMEs) { 145 TEST_F(TrayIMETest, HiddenWithNoIMEs) {
136 if (MaterialDesignController::IsSystemTrayMenuMaterial())
137 return;
138
139 SetIMELength(0); 146 SetIMELength(0);
140 EXPECT_FALSE(default_view()->visible()); 147 EXPECT_FALSE(default_view()->visible());
141 SetIMELength(1); 148 SetIMELength(1);
142 EXPECT_FALSE(default_view()->visible()); 149 EXPECT_FALSE(default_view()->visible());
143 SetIMELength(2); 150 SetIMELength(2);
144 EXPECT_TRUE(default_view()->visible()); 151 EXPECT_TRUE(default_view()->visible());
145 } 152 }
146 153
154 // Tests that if IMEs are managed, the default view is displayed even for a
155 // single IME.
156 TEST_F(TrayIMETest, ShownWithSingleIMEWhenManaged) {
157 SetManagedMessage(base::ASCIIToUTF16("managed"));
158 SetIMELength(0);
159 EXPECT_FALSE(default_view()->visible());
160 SetIMELength(1);
161 EXPECT_TRUE(default_view()->visible());
162 SetIMELength(2);
163 EXPECT_TRUE(default_view()->visible());
164 }
165
147 // Tests that if no IMEs are present the default view is hidden when a11y is 166 // Tests that if no IMEs are present the default view is hidden when a11y is
148 // enabled. 167 // enabled.
149 TEST_F(TrayIMETest, HidesOnA11yEnabled) { 168 TEST_F(TrayIMETest, HidesOnA11yEnabled) {
150 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 169 if (MaterialDesignController::IsSystemTrayMenuMaterial())
151 return; 170 return;
152 171
153 SetIMELength(0); 172 SetIMELength(0);
154 SuppressKeyboard(); 173 SuppressKeyboard();
155 EXPECT_TRUE(default_view()->visible()); 174 EXPECT_TRUE(default_view()->visible());
156 // Enable a11y keyboard. 175 // Enable a11y keyboard.
(...skipping 24 matching lines...) Expand all
181 toggle = GetScrollChildView(0); 200 toggle = GetScrollChildView(0);
182 // Clicking again should disable the keyboard. 201 // Clicking again should disable the keyboard.
183 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(), 202 tap = ui::GestureEvent(0, 0, 0, base::TimeTicks(),
184 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); 203 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
185 toggle->OnGestureEvent(&tap); 204 toggle->OnGestureEvent(&tap);
186 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); 205 EXPECT_FALSE(keyboard::IsKeyboardEnabled());
187 EXPECT_TRUE(default_view()->visible()); 206 EXPECT_TRUE(default_view()->visible());
188 } 207 }
189 208
190 } // namespace ash 209 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698