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

Unified Diff: athena/screen/screen_manager_unittest.cc

Issue 665803003: Revert of Support modal windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « athena/screen/screen_manager_impl.cc ('k') | athena/system/network_selector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/screen/screen_manager_unittest.cc
diff --git a/athena/screen/screen_manager_unittest.cc b/athena/screen/screen_manager_unittest.cc
index f9a790516cb14d84af2b12f65b97a13f7e27eb4a..ed8b248a3b2ace8cfb4b95dacf9177521cf31b0b 100644
--- a/athena/screen/screen_manager_unittest.cc
+++ b/athena/screen/screen_manager_unittest.cc
@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "athena/screen/public/screen_manager.h"
+
#include <algorithm>
#include <string>
-#include "athena/screen/screen_manager_impl.h"
#include "athena/test/base/athena_test_base.h"
-#include "athena/test/base/test_windows.h"
#include "athena/util/container_priorities.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
-#include "ui/aura/window_targeter.h"
#include "ui/events/test/event_generator.h"
#include "ui/wm/core/window_util.h"
@@ -112,82 +111,12 @@
EXPECT_TRUE(wm::CanActivateWindow(window.get()));
}
-TEST_F(ScreenManagerTest, BlockInputsShouldNotBlockVirtualKeyboard) {
- ScreenManager::ContainerParams block_params("blocking", kTestZOrderPriority);
- block_params.can_activate_children = true;
- block_params.block_events = true;
- aura::Window* block_container =
- ScreenManager::Get()->CreateContainer(block_params);
-
- aura::test::EventCountDelegate block_delegate;
- scoped_ptr<aura::Window> block_window(CreateWindow(
- block_container, &block_delegate, gfx::Rect(0, 0, 100, 100)));
- EXPECT_TRUE(wm::CanActivateWindow(block_window.get()));
-
- // Create a normal container appearing over the |block_container|. This is
- // essentially the case of virtual keyboard.
- ScreenManager::ContainerParams vk_params("virtual keyboard",
- kTestZOrderPriority + 1);
- vk_params.can_activate_children = true;
- aura::Window* vk_container = ScreenManager::Get()->CreateContainer(vk_params);
-
- aura::test::EventCountDelegate vk_delegate;
- scoped_ptr<aura::Window> vk_window(
- CreateWindow(vk_container, &vk_delegate, gfx::Rect(0, 20, 100, 80)));
- EXPECT_TRUE(wm::CanActivateWindow(vk_window.get()));
-
- ui::test::EventGenerator event_generator(root_window());
- event_generator.MoveMouseTo(10, 25);
- event_generator.ClickLeftButton();
- EXPECT_EQ("0 0", block_delegate.GetMouseButtonCountsAndReset());
- EXPECT_EQ("1 1", vk_delegate.GetMouseButtonCountsAndReset());
-}
-
-TEST_F(ScreenManagerTest, DefaultContainer) {
- ScreenManagerImpl* impl =
- static_cast<ScreenManagerImpl*>(ScreenManager::Get());
- aura::Window* original_default = impl->FindContainerByPriority(CP_DEFAULT);
- aura::Window* parent = original_default->parent();
- // Temporarily remove the original default container from tree.
- parent->RemoveChild(original_default);
-
- ScreenManager::ContainerParams params("new_default", CP_END + 1);
- params.default_parent = true;
- params.modal_container_priority = CP_END + 2;
- aura::Window* new_default = ScreenManager::Get()->CreateContainer(params);
- aura::Window* w = test::CreateNormalWindow(NULL, NULL).release();
- EXPECT_EQ(new_default, w->parent());
- delete new_default;
-
- // Add the original back to shutdown properly.
- parent->AddChild(original_default);
-}
-
-namespace {
-
-class ScreenManagerTargeterTest
- : public athena::test::AthenaTestBase,
- public testing::WithParamInterface<ui::EventTargeter*> {
- public:
- ScreenManagerTargeterTest() : targeter_(GetParam()) {}
- virtual ~ScreenManagerTargeterTest() {}
-
- protected:
- scoped_ptr<ui::EventTargeter> targeter_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScreenManagerTargeterTest);
-};
-
-} // namespace
-
-TEST_P(ScreenManagerTargeterTest, BlockContainer) {
+TEST_F(ScreenManagerTest, GrabInputContainer) {
ScreenManager::ContainerParams normal_params(
"normal", kTestZOrderPriority);
normal_params.can_activate_children = true;
aura::Window* normal_container =
ScreenManager::Get()->CreateContainer(normal_params);
- normal_container->SetEventTargeter(targeter_.Pass());
aura::test::EventCountDelegate normal_delegate;
scoped_ptr<aura::Window> normal_window(CreateWindow(
@@ -203,48 +132,76 @@
event_generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
EXPECT_EQ("1 1", normal_delegate.GetKeyCountsAndReset());
- ScreenManager::ContainerParams block_params("blocking",
- kTestZOrderPriority + 1);
- block_params.can_activate_children = true;
- block_params.block_events = true;
- aura::Window* block_container =
- ScreenManager::Get()->CreateContainer(block_params);
+ ScreenManager::ContainerParams grab_params(
+ "grabbing", kTestZOrderPriority + 1);
+ grab_params.can_activate_children = true;
+ grab_params.grab_inputs = true;
+ aura::Window* grab_container =
+ ScreenManager::Get()->CreateContainer(grab_params);
EXPECT_FALSE(wm::CanActivateWindow(normal_window.get()));
- aura::test::EventCountDelegate block_delegate;
- scoped_ptr<aura::Window> block_window(CreateWindow(
- block_container, &block_delegate, gfx::Rect(10, 10, 100, 100)));
- EXPECT_TRUE(wm::CanActivateWindow(block_window.get()));
-
- wm::ActivateWindow(block_window.get());
+ aura::test::EventCountDelegate grab_delegate;
+ scoped_ptr<aura::Window> grab_window(CreateWindow(
+ grab_container, &grab_delegate, gfx::Rect(10, 10, 100, 100)));
+ EXPECT_TRUE(wm::CanActivateWindow(grab_window.get()));
+
+ wm::ActivateWindow(grab_window.get());
// (0, 0) is still on normal_window, but the event should not go there
- // because blockbing_container prevents it.
+ // because grabbing_container prevents it.
event_generator.MoveMouseTo(0, 0);
event_generator.ClickLeftButton();
EXPECT_EQ("0 0", normal_delegate.GetMouseButtonCountsAndReset());
- EXPECT_EQ("0 0", block_delegate.GetMouseButtonCountsAndReset());
- event_generator.MoveMouseWheel(0, 10);
- // EXPECT_EQ(0, normal_event_counter.num_scroll_events());
+ EXPECT_EQ("0 0", grab_delegate.GetMouseButtonCountsAndReset());
event_generator.MoveMouseTo(20, 20);
event_generator.ClickLeftButton();
- EXPECT_EQ("1 1", block_delegate.GetMouseButtonCountsAndReset());
+ EXPECT_EQ("1 1", grab_delegate.GetMouseButtonCountsAndReset());
event_generator.PressKey(ui::VKEY_A, ui::EF_NONE);
event_generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
EXPECT_EQ("0 0", normal_delegate.GetKeyCountsAndReset());
- EXPECT_EQ("1 1", block_delegate.GetKeyCountsAndReset());
-}
-
-TEST_P(ScreenManagerTargeterTest, BlockAndMouseCapture) {
+ EXPECT_EQ("1 1", grab_delegate.GetKeyCountsAndReset());
+}
+
+TEST_F(ScreenManagerTest, GrabShouldNotBlockVirtualKeyboard) {
+ ScreenManager::ContainerParams grab_params("grabbing", kTestZOrderPriority);
+ grab_params.can_activate_children = true;
+ grab_params.grab_inputs = true;
+ aura::Window* grab_container =
+ ScreenManager::Get()->CreateContainer(grab_params);
+
+ aura::test::EventCountDelegate grab_delegate;
+ scoped_ptr<aura::Window> grab_window(
+ CreateWindow(grab_container, &grab_delegate, gfx::Rect(0, 0, 100, 100)));
+ EXPECT_TRUE(wm::CanActivateWindow(grab_window.get()));
+
+ // Create a normal container appearing over the |grab_container|. This is
+ // essentially the case of virtual keyboard.
+ ScreenManager::ContainerParams vk_params(
+ "virtual keyboard", kTestZOrderPriority + 1);
+ vk_params.can_activate_children = true;
+ aura::Window* vk_container = ScreenManager::Get()->CreateContainer(vk_params);
+
+ aura::test::EventCountDelegate vk_delegate;
+ scoped_ptr<aura::Window> vk_window(
+ CreateWindow(vk_container, &vk_delegate, gfx::Rect(0, 20, 100, 80)));
+ EXPECT_TRUE(wm::CanActivateWindow(vk_window.get()));
+
+ ui::test::EventGenerator event_generator(root_window());
+ event_generator.MoveMouseTo(10, 25);
+ event_generator.ClickLeftButton();
+ EXPECT_EQ("0 0", grab_delegate.GetMouseButtonCountsAndReset());
+ EXPECT_EQ("1 1", vk_delegate.GetMouseButtonCountsAndReset());
+}
+
+TEST_F(ScreenManagerTest, GrabAndMouseCapture) {
ScreenManager::ContainerParams normal_params(
"normal", kTestZOrderPriority);
normal_params.can_activate_children = true;
aura::Window* normal_container =
ScreenManager::Get()->CreateContainer(normal_params);
- normal_container->SetEventTargeter(targeter_.Pass());
aura::test::EventCountDelegate normal_delegate;
scoped_ptr<aura::Window> normal_window(CreateWindow(
@@ -254,34 +211,29 @@
event_generator.MoveMouseTo(0, 0);
event_generator.PressLeftButton();
- // Creating blocking container while mouse pressing.
- ScreenManager::ContainerParams block_params("blocking",
- kTestZOrderPriority + 1);
- block_params.can_activate_children = true;
- block_params.block_events = true;
- aura::Window* block_container =
- ScreenManager::Get()->CreateContainer(block_params);
-
- aura::test::EventCountDelegate block_delegate;
- scoped_ptr<aura::Window> block_window(CreateWindow(
- block_container, &block_delegate, gfx::Rect(10, 10, 100, 100)));
+ // Creating grabbing container while mouse pressing.
+ ScreenManager::ContainerParams grab_params(
+ "grabbing", kTestZOrderPriority + 1);
+ grab_params.can_activate_children = true;
+ grab_params.grab_inputs = true;
+ aura::Window* grab_container =
+ ScreenManager::Get()->CreateContainer(grab_params);
+
+ aura::test::EventCountDelegate grab_delegate;
+ scoped_ptr<aura::Window> grab_window(CreateWindow(
+ grab_container, &grab_delegate, gfx::Rect(10, 10, 100, 100)));
// Release event should be sent to |normal_window| because it captures the
// mouse event.
event_generator.ReleaseLeftButton();
EXPECT_EQ("1 1", normal_delegate.GetMouseButtonCountsAndReset());
- EXPECT_EQ("0 0", block_delegate.GetMouseButtonCountsAndReset());
+ EXPECT_EQ("0 0", grab_delegate.GetMouseButtonCountsAndReset());
// After release, further mouse events should not be sent to |normal_window|
- // because block_container blocks the input.
+ // because grab_container grabs the input.
event_generator.ClickLeftButton();
EXPECT_EQ("0 0", normal_delegate.GetMouseButtonCountsAndReset());
- EXPECT_EQ("0 0", block_delegate.GetMouseButtonCountsAndReset());
-}
-
-INSTANTIATE_TEST_CASE_P(WithOrWithoutTargeter,
- ScreenManagerTargeterTest,
- testing::Values(static_cast<ui::EventTargeter*>(NULL),
- new aura::WindowTargeter));
+ EXPECT_EQ("0 0", grab_delegate.GetMouseButtonCountsAndReset());
+}
} // namespace athena
« no previous file with comments | « athena/screen/screen_manager_impl.cc ('k') | athena/system/network_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698