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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2554513002: Change |EnsureCaretInRect| to |EnsureCaretNotInRect|. (Closed)
Patch Set: update the added test Created 4 years 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
« no previous file with comments | « ash/common/wm/window_state.h ('k') | components/arc/ime/arc_ime_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } 716 }
717 717
718 private: 718 private:
719 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest); 719 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardRootWindowControllerTest);
720 }; 720 };
721 721
722 class MockTextInputClient : public ui::DummyTextInputClient { 722 class MockTextInputClient : public ui::DummyTextInputClient {
723 public: 723 public:
724 MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {} 724 MockTextInputClient() : ui::DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {}
725 725
726 void EnsureCaretInRect(const gfx::Rect& rect) override { 726 void EnsureCaretNotInRect(const gfx::Rect& rect) override {
727 visible_rect_ = rect; 727 hidden_rect_ = rect;
sky 2016/12/07 05:06:20 hidden_rect_ doesn't really relate to the name of
yhanada 2016/12/07 06:15:25 Done.
728 } 728 }
729 729
730 const gfx::Rect& visible_rect() const { return visible_rect_; } 730 const gfx::Rect& hidden_rect() const { return hidden_rect_; }
731 731
732 private: 732 private:
733 gfx::Rect visible_rect_; 733 gfx::Rect hidden_rect_;
734 734
735 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); 735 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient);
736 }; 736 };
737 737
738 class TargetHitTestEventHandler : public ui::test::TestEventHandler { 738 class TargetHitTestEventHandler : public ui::test::TestEventHandler {
739 public: 739 public:
740 TargetHitTestEventHandler() {} 740 TargetHitTestEventHandler() {}
741 741
742 // ui::test::TestEventHandler overrides. 742 // ui::test::TestEventHandler overrides.
743 void OnMouseEvent(ui::MouseEvent* event) override { 743 void OnMouseEvent(ui::MouseEvent* event) override {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1076
1077 const int keyboard_height = 100; 1077 const int keyboard_height = 100;
1078 aura::Window* keyboard_window = ui->GetKeyboardWindow(); 1078 aura::Window* keyboard_window = ui->GetKeyboardWindow();
1079 keyboard_container->AddChild(keyboard_window); 1079 keyboard_container->AddChild(keyboard_window);
1080 keyboard_window->set_owned_by_parent(false); 1080 keyboard_window->set_owned_by_parent(false);
1081 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds( 1081 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
1082 root_window->bounds(), keyboard_height)); 1082 root_window->bounds(), keyboard_height));
1083 1083
1084 ui->EnsureCaretInWorkArea(); 1084 ui->EnsureCaretInWorkArea();
1085 ASSERT_EQ(root_window->bounds().width(), 1085 ASSERT_EQ(root_window->bounds().width(),
1086 text_input_client.visible_rect().width()); 1086 text_input_client.hidden_rect().width());
1087 ASSERT_EQ(root_window->bounds().height() - keyboard_height, 1087 ASSERT_EQ(keyboard_height, text_input_client.hidden_rect().height());
1088 text_input_client.visible_rect().height());
1089 1088
1090 input_method->SetFocusedTextInputClient(NULL); 1089 input_method->SetFocusedTextInputClient(NULL);
1091 } 1090 }
1092 1091
1092 TEST_F(VirtualKeyboardRootWindowControllerTest,
1093 EnsureCaretInWorkAreaWithMultipleDisplays) {
1094 if (!SupportsMultipleDisplays())
1095 return;
1096
1097 UpdateDisplay("500x500,600x600");
1098 const int64_t primary_display_id =
1099 display::Screen::GetScreen()->GetPrimaryDisplay().id();
1100 const int64_t secondary_display_id =
1101 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id();
1102 ASSERT_NE(primary_display_id, secondary_display_id);
1103
1104 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1105 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow();
sky 2016/12/07 05:06:21 Why don't you set primary to root_windows[0] and s
yhanada 2016/12/07 06:15:25 Done.
1106 aura::Window* secondary_root_window = root_windows[0] == primary_root_window
1107 ? root_windows[1]
1108 : root_windows[0];
1109 ASSERT_NE(primary_root_window, secondary_root_window);
1110
1111 keyboard::KeyboardController* keyboard_controller =
1112 keyboard::KeyboardController::GetInstance();
1113 keyboard::KeyboardUI* ui = keyboard_controller->ui();
1114
1115 MockTextInputClient text_input_client;
1116 ui::InputMethod* input_method = ui->GetInputMethod();
1117 ASSERT_TRUE(input_method);
1118 input_method->SetFocusedTextInputClient(&text_input_client);
1119
1120 const int keyboard_height = 100;
1121 // Check that the keyboard on the primary screen doesn't cover the window on
1122 // the secondary screen.
1123 aura::Window* keyboard_container = Shell::GetContainer(
1124 primary_root_window, kShellWindowId_VirtualKeyboardContainer);
1125 ASSERT_TRUE(keyboard_container);
1126 keyboard_container->Show();
1127 aura::Window* keyboard_window = ui->GetKeyboardWindow();
1128 keyboard_container->AddChild(keyboard_window);
1129 keyboard_window->set_owned_by_parent(false);
1130 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
1131 primary_root_window->bounds(), keyboard_height));
1132
1133 EXPECT_TRUE(primary_root_window->GetBoundsInScreen().Contains(
1134 text_input_client.hidden_rect()));
1135 EXPECT_FALSE(secondary_root_window->GetBoundsInScreen().Contains(
1136 text_input_client.hidden_rect()));
1137
1138 // Move the keyboard into the secondary display and check that the keyboard
1139 // doesn't cover the window on the primary screen.
1140 keyboard_controller->ShowKeyboardInDisplay(secondary_display_id);
1141 keyboard_container->Show();
sky 2016/12/07 05:06:21 Is this really necessary? Isn't this the same as l
yhanada 2016/12/07 06:15:25 Done.
1142 keyboard_window->SetBounds(keyboard::FullWidthKeyboardBoundsFromRootBounds(
1143 secondary_root_window->bounds(), keyboard_height));
1144
1145 ui->EnsureCaretInWorkArea();
1146 EXPECT_FALSE(primary_root_window->GetBoundsInScreen().Contains(
1147 text_input_client.hidden_rect()));
1148 EXPECT_TRUE(secondary_root_window->GetBoundsInScreen().Contains(
1149 text_input_client.hidden_rect()));
1150
1151 input_method->SetFocusedTextInputClient(nullptr);
1152 }
1153
1093 // Tests that the virtual keyboard does not block context menus. The virtual 1154 // Tests that the virtual keyboard does not block context menus. The virtual
1094 // keyboard should appear in front of most content, but not context menus. See 1155 // keyboard should appear in front of most content, but not context menus. See
1095 // crbug/377180. 1156 // crbug/377180.
1096 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { 1157 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) {
1097 UpdateDisplay("800x600"); 1158 UpdateDisplay("800x600");
1098 keyboard::KeyboardController* keyboard_controller = 1159 keyboard::KeyboardController* keyboard_controller =
1099 keyboard::KeyboardController::GetInstance(); 1160 keyboard::KeyboardController::GetInstance();
1100 keyboard::KeyboardUI* ui = keyboard_controller->ui(); 1161 keyboard::KeyboardUI* ui = keyboard_controller->ui();
1101 1162
1102 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 1163 aura::Window* root_window = Shell::GetPrimaryRootWindow();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1256 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1196 gfx::Rect(0, 400, 800, 200)); 1257 gfx::Rect(0, 400, 800, 200));
1197 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1258 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1198 1259
1199 UpdateDisplay("600x800"); 1260 UpdateDisplay("600x800");
1200 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1261 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1201 } 1262 }
1202 1263
1203 } // namespace test 1264 } // namespace test
1204 } // namespace ash 1265 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/window_state.h ('k') | components/arc/ime/arc_ime_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698