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

Unified Diff: ash/root_window_controller_unittest.cc

Issue 22465007: Whitelist virtual keyboard container to process events at login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit tests for virtual keyboard container Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ash/root_window_controller_unittest.cc
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index b27cc52ca1ad3b59c8b4a4b4de12a28e2b7e3c4d..48daee2af21ee7cf3149f7825d5c2f06e36502b7 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -13,6 +13,7 @@
#include "ash/wm/system_modal_container_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
+#include "base/command_line.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/env.h"
@@ -22,6 +23,7 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tracker.h"
+#include "ui/keyboard/keyboard_switches.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -80,6 +82,35 @@ class DeleteOnBlurDelegate : public aura::test::TestWindowDelegate,
DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate);
};
+class ClickTestWindow : public views::WidgetDelegateView {
+ public:
+ ClickTestWindow() : mouse_presses_(0) {}
+ virtual ~ClickTestWindow() {}
+
+ // Overridden from views::WidgetDelegate:
+ virtual views::View* GetContentsView() OVERRIDE {
+ return this;
+ }
+
+ aura::Window* CreateTestWindowWithParent(aura::Window* parent) {
+ DCHECK(parent);
+ views::Widget* widget = Widget::CreateWindowWithParent(this, parent);
+ return widget->GetNativeView();
+ }
+
+ // Overridden from views::View:
+ virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
+ mouse_presses_++;
+ return false;
+ }
+
+ int mouse_presses() const { return mouse_presses_; }
James Cook 2013/08/08 17:29:44 nit: blank line after this
bshe 2013/08/08 19:39:24 Done.
+ private:
+ int mouse_presses_;
+
+ DISALLOW_COPY_AND_ASSIGN(ClickTestWindow);
+};
+
} // namespace
namespace test {
@@ -473,5 +504,47 @@ TEST_F(RootWindowControllerTest, FocusBlockedWindow) {
}
}
+class VirtualKeyboardRootWindowControllerTest : public test::AshTestBase {
+ public:
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ keyboard::switches::kEnableVirtualKeyboard);
+ test::AshTestBase::SetUp();
+ }
oshima 2013/08/08 17:19:29 nit: DISALLOW_COPY_AND_ASSIGN
bshe 2013/08/08 19:37:02 Done.
+};
+
+// Test for http://crbug.com/263599. Virtual keyboard should be able to receive
+// events at blocked user session.
+TEST_F(VirtualKeyboardRootWindowControllerTest,
+ ClickVirtualKeyboardInBlockedWindow) {
+ UpdateDisplay("600x600");
oshima 2013/08/08 17:19:29 do you need to change the size of the display for
bshe 2013/08/08 19:37:02 No. I was just following the above example. It is
+ aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
oshima 2013/08/08 17:19:29 GetPrimaryRootWindow is static
bshe 2013/08/08 19:37:02 Done.
+ aura::Window* vk_container = Shell::GetContainer(root_window,
James Cook 2013/08/08 17:29:44 no abbreviations: vk_container -> keyboard_contain
bshe 2013/08/08 19:39:24 Done.
+ internal::kShellWindowId_VirtualKeyboardContainer);
+ CHECK(vk_container);
James Cook 2013/08/08 17:29:44 optional nit: ASSERT_TRUE ?
bshe 2013/08/08 19:39:24 Done.
+ vk_container->Show();
+
+ ClickTestWindow* main_delegate = new ClickTestWindow();
+ scoped_ptr<aura::Window> vk_window(
James Cook 2013/08/08 17:29:44 vk_window -> keyboard_window or similar
bshe 2013/08/08 19:39:24 Done.
+ main_delegate->CreateTestWindowWithParent(vk_container));
+ vk_container->layout_manager()->OnWindowResized();
+ vk_window->Show();
+ aura::test::EventGenerator event_generator(root_window,
+ vk_window.get());
+ event_generator.ClickLeftButton();
+ int expected_mouse_presses = 1;
+ EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses());
+
+ for (int block_reason = FIRST_BLOCK_REASON;
+ block_reason < NUMBER_OF_BLOCK_REASONS;
+ ++block_reason) {
+ BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
+ event_generator.ClickLeftButton();
+ expected_mouse_presses++;
+ EXPECT_EQ(expected_mouse_presses, main_delegate->mouse_presses());
+ UnblockUserSession();
+ }
+}
+
} // namespace test
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698