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

Unified Diff: ui/aura_shell/root_window_event_filter_unittest.cc

Issue 8894018: Move the concept of Activation to the Shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura_shell/root_window_event_filter.cc ('k') | ui/aura_shell/shadow_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura_shell/root_window_event_filter_unittest.cc
===================================================================
--- ui/aura_shell/root_window_event_filter_unittest.cc (revision 114022)
+++ ui/aura_shell/root_window_event_filter_unittest.cc (working copy)
@@ -4,6 +4,8 @@
#include "ui/aura_shell/root_window_event_filter.h"
+#include "ui/aura/client/activation_delegate.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/cursor.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
@@ -13,7 +15,10 @@
#include "ui/aura/test/test_event_filter.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_stacking_client.h"
+#include "ui/aura_shell/activation_controller.h"
#include "ui/aura_shell/shell_window_ids.h"
+#include "ui/aura_shell/test/test_activation_delegate.h"
+#include "ui/aura_shell/window_util.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/screen.h"
@@ -31,12 +36,17 @@
aura::RootWindow::GetInstance()->stacking_client());
stacking_client->default_container()->set_id(
internal::kShellWindowId_DefaultContainer);
+ activation_controller_.reset(new internal::ActivationController);
+ activation_controller_->set_default_container_for_test(
+ stacking_client->default_container());
}
virtual ~RootWindowEventFilterTest() {
aura::RootWindow::GetInstance()->SetEventFilter(NULL);
}
private:
+ scoped_ptr<internal::ActivationController> activation_controller_;
+
DISALLOW_COPY_AND_ASSIGN(RootWindowEventFilterTest);
};
@@ -124,63 +134,72 @@
TEST_F(RootWindowEventFilterTest, ActivateOnMouse) {
aura::RootWindow* root_window = aura::RootWindow::GetInstance();
- aura::test::ActivateWindowDelegate d1;
+ TestActivationDelegate d1;
+ aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
- &d1, 1, gfx::Rect(10, 10, 50, 50), NULL));
- aura::test::ActivateWindowDelegate d2;
+ &wd, 1, gfx::Rect(10, 10, 50, 50), NULL));
+ d1.SetWindow(w1.get());
+ TestActivationDelegate d2;
scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
- &d2, 2, gfx::Rect(70, 70, 50, 50), NULL));
+ &wd, 2, gfx::Rect(70, 70, 50, 50), NULL));
+ d2.SetWindow(w2.get());
+
aura::internal::FocusManager* focus_manager = w1->GetFocusManager();
d1.Clear();
d2.Clear();
// Activate window1.
- root_window->SetActiveWindow(w1.get(), NULL);
- EXPECT_EQ(w1.get(), root_window->active_window());
+ aura_shell::ActivateWindow(w1.get());
+ EXPECT_TRUE(IsActiveWindow(w1.get()));
EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(1, d1.activated_count());
EXPECT_EQ(0, d1.lost_active_count());
d1.Clear();
- // Click on window2.
- gfx::Point press_point = w2->bounds().CenterPoint();
- aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point);
- aura::test::EventGenerator generator(press_point);
- generator.ClickLeftButton();
+ {
+ // Click on window2.
+ gfx::Point press_point = w2->bounds().CenterPoint();
+ aura::Window::ConvertPointToWindow(w2->parent(), root_window, &press_point);
+ aura::test::EventGenerator generator(press_point);
+ generator.ClickLeftButton();
- // Window2 should have become active.
- EXPECT_EQ(w2.get(), root_window->active_window());
- EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
- EXPECT_EQ(0, d1.activated_count());
- EXPECT_EQ(1, d1.lost_active_count());
- EXPECT_EQ(1, d2.activated_count());
- EXPECT_EQ(0, d2.lost_active_count());
- d1.Clear();
- d2.Clear();
+ // Window2 should have become active.
+ EXPECT_TRUE(IsActiveWindow(w2.get()));
+ EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
+ EXPECT_EQ(0, d1.activated_count());
+ EXPECT_EQ(1, d1.lost_active_count());
+ EXPECT_EQ(1, d2.activated_count());
+ EXPECT_EQ(0, d2.lost_active_count());
+ d1.Clear();
+ d2.Clear();
+ }
- // Click back on window1, but set it up so w1 doesn't activate on click.
- press_point = w1->bounds().CenterPoint();
- aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point);
- d1.set_activate(false);
- generator.ClickLeftButton();
+ {
+ // Click back on window1, but set it up so w1 doesn't activate on click.
+ gfx::Point press_point = w1->bounds().CenterPoint();
+ aura::Window::ConvertPointToWindow(w1->parent(), root_window, &press_point);
+ aura::test::EventGenerator generator(press_point);
+ d1.set_activate(false);
+ generator.ClickLeftButton();
- // Window2 should still be active and focused.
- EXPECT_EQ(w2.get(), root_window->active_window());
- EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
- EXPECT_EQ(0, d1.activated_count());
- EXPECT_EQ(0, d1.lost_active_count());
- EXPECT_EQ(0, d2.activated_count());
- EXPECT_EQ(0, d2.lost_active_count());
- d1.Clear();
- d2.Clear();
+ // Window2 should still be active and focused.
+ EXPECT_TRUE(IsActiveWindow(w2.get()));
+ EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
+ EXPECT_EQ(0, d1.activated_count());
+ EXPECT_EQ(0, d1.lost_active_count());
+ EXPECT_EQ(0, d2.activated_count());
+ EXPECT_EQ(0, d2.lost_active_count());
+ d1.Clear();
+ d2.Clear();
+ }
// Destroy window2, this should make window1 active.
d1.set_activate(true);
w2.reset();
EXPECT_EQ(0, d2.activated_count());
EXPECT_EQ(0, d2.lost_active_count());
- EXPECT_EQ(w1.get(), root_window->active_window());
+ EXPECT_TRUE(IsActiveWindow(w1.get()));
EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(1, d1.activated_count());
EXPECT_EQ(0, d1.lost_active_count());
@@ -190,20 +209,24 @@
TEST_F(RootWindowEventFilterTest, ActivateOnTouch) {
aura::RootWindow* root_window = aura::RootWindow::GetInstance();
- aura::test::ActivateWindowDelegate d1;
+ TestActivationDelegate d1;
+ aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
- &d1, -1, gfx::Rect(10, 10, 50, 50), NULL));
- aura::test::ActivateWindowDelegate d2;
+ &wd, -1, gfx::Rect(10, 10, 50, 50), NULL));
+ d1.SetWindow(w1.get());
+ TestActivationDelegate d2;
scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
- &d2, -2, gfx::Rect(70, 70, 50, 50), NULL));
+ &wd, -2, gfx::Rect(70, 70, 50, 50), NULL));
+ d2.SetWindow(w2.get());
+
aura::internal::FocusManager* focus_manager = w1->GetFocusManager();
d1.Clear();
d2.Clear();
// Activate window1.
- root_window->SetActiveWindow(w1.get(), NULL);
- EXPECT_EQ(w1.get(), root_window->active_window());
+ aura_shell::ActivateWindow(w1.get());
+ EXPECT_TRUE(IsActiveWindow(w1.get()));
EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(1, d1.activated_count());
EXPECT_EQ(0, d1.lost_active_count());
@@ -216,7 +239,7 @@
root_window->DispatchTouchEvent(&touchev1);
// Window2 should have become active.
- EXPECT_EQ(w2.get(), root_window->active_window());
+ EXPECT_TRUE(IsActiveWindow(w2.get()));
EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(0, d1.activated_count());
EXPECT_EQ(1, d1.lost_active_count());
@@ -233,7 +256,7 @@
root_window->DispatchTouchEvent(&touchev2);
// Window2 should still be active and focused.
- EXPECT_EQ(w2.get(), root_window->active_window());
+ EXPECT_TRUE(IsActiveWindow(w2.get()));
EXPECT_EQ(w2.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(0, d1.activated_count());
EXPECT_EQ(0, d1.lost_active_count());
@@ -247,7 +270,7 @@
w2.reset();
EXPECT_EQ(0, d2.activated_count());
EXPECT_EQ(0, d2.lost_active_count());
- EXPECT_EQ(w1.get(), root_window->active_window());
+ EXPECT_TRUE(IsActiveWindow(w1.get()));
EXPECT_EQ(w1.get(), focus_manager->GetFocusedWindow());
EXPECT_EQ(1, d1.activated_count());
EXPECT_EQ(0, d1.lost_active_count());
@@ -329,9 +352,11 @@
transform.ConcatTranslate(size.width(), 0);
root_window->SetTransform(transform);
- aura::test::ActivateWindowDelegate d1;
+ TestActivationDelegate d1;
+ aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> w1(
- CreateTestWindowWithDelegate(&d1, 1, gfx::Rect(0, 10, 50, 50), NULL));
+ CreateTestWindowWithDelegate(&wd, 1, gfx::Rect(0, 10, 50, 50), NULL));
+ d1.SetWindow(w1.get());
w1->Show();
gfx::Point miss_point(5, 5);
@@ -352,7 +377,7 @@
hit_point,
ui::EF_LEFT_BUTTON_DOWN);
root_window->DispatchMouseEvent(&mouseev2);
- EXPECT_EQ(w1.get(), root_window->active_window());
+ EXPECT_TRUE(IsActiveWindow(w1.get()));
EXPECT_EQ(w1.get(), w1->GetFocusManager()->GetFocusedWindow());
}
@@ -362,7 +387,7 @@
// Creates a window and make it active
scoped_ptr<aura::Window> w1(aura::test::CreateTestWindow(
SK_ColorWHITE, -1, gfx::Rect(0, 0, 100, 100), NULL));
- root_window->SetActiveWindow(w1.get(), NULL);
+ aura_shell::ActivateWindow(w1.get());
// Creates two addition filters
scoped_ptr<aura::test::TestEventFilter> f1(
« no previous file with comments | « ui/aura_shell/root_window_event_filter.cc ('k') | ui/aura_shell/shadow_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698