OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 264 |
265 parent.StackChildAtTop(&child1); | 265 parent.StackChildAtTop(&child1); |
266 ASSERT_EQ(2u, parent.children().size()); | 266 ASSERT_EQ(2u, parent.children().size()); |
267 EXPECT_EQ(&child1, parent.children()[1]); | 267 EXPECT_EQ(&child1, parent.children()[1]); |
268 EXPECT_EQ(&child2, parent.children()[0]); | 268 EXPECT_EQ(&child2, parent.children()[0]); |
269 ASSERT_EQ(2u, parent.layer()->children().size()); | 269 ASSERT_EQ(2u, parent.layer()->children().size()); |
270 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); | 270 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); |
271 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); | 271 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); |
272 } | 272 } |
273 | 273 |
274 // Various assertions for StackAtTop. | 274 // Various assertions for StackChildAbove. |
275 TEST_F(WindowTest, StackAtTop) { | 275 TEST_F(WindowTest, StackChildAbove) { |
276 Window parent(NULL); | 276 Window parent(NULL); |
277 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 277 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
278 Window child1(NULL); | 278 Window child1(NULL); |
279 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 279 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
280 Window child2(NULL); | 280 Window child2(NULL); |
281 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 281 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
282 Window child3(NULL); | 282 Window child3(NULL); |
283 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 283 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
284 | 284 |
285 child1.SetParent(&parent); | 285 child1.SetParent(&parent); |
(...skipping 14 matching lines...) Expand all Loading... |
300 parent.StackChildAbove(&child2, &child1); | 300 parent.StackChildAbove(&child2, &child1); |
301 ASSERT_EQ(3u, parent.children().size()); | 301 ASSERT_EQ(3u, parent.children().size()); |
302 EXPECT_EQ(&child1, parent.children()[0]); | 302 EXPECT_EQ(&child1, parent.children()[0]); |
303 EXPECT_EQ(&child2, parent.children()[1]); | 303 EXPECT_EQ(&child2, parent.children()[1]); |
304 EXPECT_EQ(&child3, parent.children()[2]); | 304 EXPECT_EQ(&child3, parent.children()[2]); |
305 ASSERT_EQ(3u, parent.layer()->children().size()); | 305 ASSERT_EQ(3u, parent.layer()->children().size()); |
306 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); | 306 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]); |
307 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); | 307 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]); |
308 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]); | 308 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]); |
309 | 309 |
310 // Move 1 in front of 3, resulting in [2 3 1]. | 310 // Move 1 in front of 3, resulting in [2, 3, 1]. |
311 parent.StackChildAbove(&child1, &child3); | 311 parent.StackChildAbove(&child1, &child3); |
312 ASSERT_EQ(3u, parent.children().size()); | 312 ASSERT_EQ(3u, parent.children().size()); |
313 EXPECT_EQ(&child2, parent.children()[0]); | 313 EXPECT_EQ(&child2, parent.children()[0]); |
314 EXPECT_EQ(&child3, parent.children()[1]); | 314 EXPECT_EQ(&child3, parent.children()[1]); |
315 EXPECT_EQ(&child1, parent.children()[2]); | 315 EXPECT_EQ(&child1, parent.children()[2]); |
316 ASSERT_EQ(3u, parent.layer()->children().size()); | 316 ASSERT_EQ(3u, parent.layer()->children().size()); |
317 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); | 317 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); |
318 EXPECT_EQ(child3.layer(), parent.layer()->children()[1]); | 318 EXPECT_EQ(child3.layer(), parent.layer()->children()[1]); |
319 EXPECT_EQ(child1.layer(), parent.layer()->children()[2]); | 319 EXPECT_EQ(child1.layer(), parent.layer()->children()[2]); |
| 320 |
| 321 // Moving 1 in front of 2 should lower it, resulting in [2, 1, 3]. |
| 322 parent.StackChildAbove(&child1, &child2); |
| 323 ASSERT_EQ(3u, parent.children().size()); |
| 324 EXPECT_EQ(&child2, parent.children()[0]); |
| 325 EXPECT_EQ(&child1, parent.children()[1]); |
| 326 EXPECT_EQ(&child3, parent.children()[2]); |
| 327 ASSERT_EQ(3u, parent.layer()->children().size()); |
| 328 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); |
| 329 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); |
| 330 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]); |
320 } | 331 } |
321 | 332 |
322 // Various destruction assertions. | 333 // Various destruction assertions. |
323 TEST_F(WindowTest, CaptureTests) { | 334 TEST_F(WindowTest, CaptureTests) { |
324 aura::Desktop* desktop = aura::Desktop::GetInstance(); | 335 aura::Desktop* desktop = aura::Desktop::GetInstance(); |
325 CaptureWindowDelegateImpl delegate; | 336 CaptureWindowDelegateImpl delegate; |
326 scoped_ptr<Window> window(CreateTestWindowWithDelegate( | 337 scoped_ptr<Window> window(CreateTestWindowWithDelegate( |
327 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); | 338 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); |
328 EXPECT_FALSE(window->HasCapture()); | 339 EXPECT_FALSE(window->HasCapture()); |
329 | 340 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 | 1097 |
1087 w3->Activate(); | 1098 w3->Activate(); |
1088 EXPECT_EQ(w2.get(), active()); | 1099 EXPECT_EQ(w2.get(), active()); |
1089 | 1100 |
1090 w1->Activate(); | 1101 w1->Activate(); |
1091 EXPECT_EQ(w1.get(), active()); | 1102 EXPECT_EQ(w1.get(), active()); |
1092 } | 1103 } |
1093 | 1104 |
1094 } // namespace test | 1105 } // namespace test |
1095 } // namespace aura | 1106 } // namespace aura |
OLD | NEW |