| OLD | NEW |
| 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/wm/window_modality_controller.h" | 5 #include "ash/wm/window_modality_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/capture_tracking_view.h" | 9 #include "ash/test/capture_tracking_view.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 aura::test::TestWindowDelegate d; | 180 aura::test::TestWindowDelegate d; |
| 181 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(&d, -1, | 181 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(&d, -1, |
| 182 gfx::Rect(0, 0, 100, 100), NULL)); | 182 gfx::Rect(0, 0, 100, 100), NULL)); |
| 183 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindowWithDelegate(&d, -11, | 183 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindowWithDelegate(&d, -11, |
| 184 gfx::Rect(20, 20, 50, 50), NULL)); | 184 gfx::Rect(20, 20, 50, 50), NULL)); |
| 185 | 185 |
| 186 w1->AddTransientChild(w11.get()); | 186 w1->AddTransientChild(w11.get()); |
| 187 | 187 |
| 188 { | 188 { |
| 189 // Clicking a point within w1 should activate that window. | 189 // Clicking a point within w1 should activate that window. |
| 190 aura::test::EventGenerator generator(Shell::GetRootWindow(), | 190 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 191 gfx::Point(10, 10)); | 191 gfx::Point(10, 10)); |
| 192 generator.ClickLeftButton(); | 192 generator.ClickLeftButton(); |
| 193 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 193 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 194 } | 194 } |
| 195 | 195 |
| 196 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 196 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 197 | 197 |
| 198 { | 198 { |
| 199 // Clicking a point within w1 should activate w11. | 199 // Clicking a point within w1 should activate w11. |
| 200 aura::test::EventGenerator generator(Shell::GetRootWindow(), | 200 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 201 gfx::Point(10, 10)); | 201 gfx::Point(10, 10)); |
| 202 generator.ClickLeftButton(); | 202 generator.ClickLeftButton(); |
| 203 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); | 203 EXPECT_TRUE(wm::IsActiveWindow(w11.get())); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Creates windows w1 and non activatiable child w11. Creates transient window | 207 // Creates windows w1 and non activatiable child w11. Creates transient window |
| 208 // w2 and adds it as a transeint child of w1. Ensures that w2 is parented to | 208 // w2 and adds it as a transeint child of w1. Ensures that w2 is parented to |
| 209 // the parent of w1, and that GetWindowModalTransient(w11) returns w2. | 209 // the parent of w1, and that GetWindowModalTransient(w11) returns w2. |
| 210 TEST_F(WindowModalityControllerTest, GetWindowModalTransient) { | 210 TEST_F(WindowModalityControllerTest, GetWindowModalTransient) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 views::Widget* widget = views::Widget::CreateWindow(NULL); | 242 views::Widget* widget = views::Widget::CreateWindow(NULL); |
| 243 scoped_ptr<aura::Window> widget_window(widget->GetNativeView()); | 243 scoped_ptr<aura::Window> widget_window(widget->GetNativeView()); |
| 244 test::CaptureTrackingView* view = new test::CaptureTrackingView; | 244 test::CaptureTrackingView* view = new test::CaptureTrackingView; |
| 245 widget->client_view()->AddChildView(view); | 245 widget->client_view()->AddChildView(view); |
| 246 widget->SetBounds(gfx::Rect(0, 0, 200, 200)); | 246 widget->SetBounds(gfx::Rect(0, 0, 200, 200)); |
| 247 view->SetBoundsRect(widget->client_view()->GetLocalBounds()); | 247 view->SetBoundsRect(widget->client_view()->GetLocalBounds()); |
| 248 widget->Show(); | 248 widget->Show(); |
| 249 | 249 |
| 250 gfx::Point center(view->width() / 2, view->height() / 2); | 250 gfx::Point center(view->width() / 2, view->height() / 2); |
| 251 views::View::ConvertPointToScreen(view, ¢er); | 251 views::View::ConvertPointToScreen(view, ¢er); |
| 252 aura::test::EventGenerator generator(Shell::GetRootWindow(), center); | 252 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), center); |
| 253 generator.PressLeftButton(); | 253 generator.PressLeftButton(); |
| 254 EXPECT_TRUE(view->got_press()); | 254 EXPECT_TRUE(view->got_press()); |
| 255 | 255 |
| 256 views::Widget* modal_widget = | 256 views::Widget* modal_widget = |
| 257 views::Widget::CreateWindowWithParent(NULL, widget->GetNativeView()); | 257 views::Widget::CreateWindowWithParent(NULL, widget->GetNativeView()); |
| 258 scoped_ptr<aura::Window> modal_window(modal_widget->GetNativeView()); | 258 scoped_ptr<aura::Window> modal_window(modal_widget->GetNativeView()); |
| 259 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 259 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 260 test::CaptureTrackingView* modal_view = new test::CaptureTrackingView; | 260 test::CaptureTrackingView* modal_view = new test::CaptureTrackingView; |
| 261 modal_widget->client_view()->AddChildView(modal_view); | 261 modal_widget->client_view()->AddChildView(modal_view); |
| 262 modal_widget->SetBounds(gfx::Rect(50, 50, 200, 200)); | 262 modal_widget->SetBounds(gfx::Rect(50, 50, 200, 200)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 277 generator.PressLeftButton(); | 277 generator.PressLeftButton(); |
| 278 EXPECT_TRUE(modal_view->got_press()); | 278 EXPECT_TRUE(modal_view->got_press()); |
| 279 EXPECT_FALSE(modal_view->got_capture_lost()); | 279 EXPECT_FALSE(modal_view->got_capture_lost()); |
| 280 EXPECT_FALSE(view->got_capture_lost()); | 280 EXPECT_FALSE(view->got_capture_lost()); |
| 281 EXPECT_FALSE(view->got_press()); | 281 EXPECT_FALSE(view->got_press()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 } // namespace internal | 285 } // namespace internal |
| 286 } // namespace ash | 286 } // namespace ash |
| OLD | NEW |