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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 8477019: Adds Window::MoveChildToFront, with surrounding changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | ui/gfx/compositor/layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 parent.MoveChildToFront(&child1); 385 parent.MoveChildToFront(&child1);
386 ASSERT_EQ(2u, parent.children().size()); 386 ASSERT_EQ(2u, parent.children().size());
387 EXPECT_EQ(&child1, parent.children()[1]); 387 EXPECT_EQ(&child1, parent.children()[1]);
388 EXPECT_EQ(&child2, parent.children()[0]); 388 EXPECT_EQ(&child2, parent.children()[0]);
389 ASSERT_EQ(2u, parent.layer()->children().size()); 389 ASSERT_EQ(2u, parent.layer()->children().size());
390 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]); 390 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
391 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]); 391 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
392 } 392 }
393 393
394 // Various assertions for MoveToFront.
395 TEST_F(WindowTest, MoveToFront) {
396 Window parent(NULL);
397 parent.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
398 Window child1(NULL);
399 child1.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
400 Window child2(NULL);
401 child2.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
402 Window child3(NULL);
403 child3.Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
404
405 child1.SetParent(&parent);
406 child2.SetParent(&parent);
407
408 // Move 1 in front of 2.
409 parent.MoveChildAbove(&child1, &child2);
410 ASSERT_EQ(2u, parent.children().size());
411 EXPECT_EQ(&child2, parent.children()[0]);
412 EXPECT_EQ(&child1, parent.children()[1]);
413 ASSERT_EQ(2u, parent.layer()->children().size());
414 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
415 EXPECT_EQ(child1.layer(), parent.layer()->children()[1]);
416
417 // Add 3, resulting in order [2, 1, 3], then move 2 in front of 1, resulting
418 // in [1, 2, 3].
419 child3.SetParent(&parent);
420 parent.MoveChildAbove(&child2, &child1);
421 ASSERT_EQ(3u, parent.children().size());
422 EXPECT_EQ(&child1, parent.children()[0]);
423 EXPECT_EQ(&child2, parent.children()[1]);
424 EXPECT_EQ(&child3, parent.children()[2]);
425 ASSERT_EQ(3u, parent.layer()->children().size());
426 EXPECT_EQ(child1.layer(), parent.layer()->children()[0]);
427 EXPECT_EQ(child2.layer(), parent.layer()->children()[1]);
428 EXPECT_EQ(child3.layer(), parent.layer()->children()[2]);
429
430 // Move 1 in front of 3, resulting in [2 3 1].
431 parent.MoveChildAbove(&child1, &child3);
432 ASSERT_EQ(3u, parent.children().size());
433 EXPECT_EQ(&child2, parent.children()[0]);
434 EXPECT_EQ(&child3, parent.children()[1]);
435 EXPECT_EQ(&child1, parent.children()[2]);
436 ASSERT_EQ(3u, parent.layer()->children().size());
437 EXPECT_EQ(child2.layer(), parent.layer()->children()[0]);
438 EXPECT_EQ(child3.layer(), parent.layer()->children()[1]);
439 EXPECT_EQ(child1.layer(), parent.layer()->children()[2]);
440 }
441
394 // Various destruction assertions. 442 // Various destruction assertions.
395 TEST_F(WindowTest, CaptureTests) { 443 TEST_F(WindowTest, CaptureTests) {
396 aura::Desktop* desktop = aura::Desktop::GetInstance(); 444 aura::Desktop* desktop = aura::Desktop::GetInstance();
397 CaptureWindowDelegateImpl delegate; 445 CaptureWindowDelegateImpl delegate;
398 scoped_ptr<Window> window(CreateTestWindowWithDelegate( 446 scoped_ptr<Window> window(CreateTestWindowWithDelegate(
399 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); 447 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL));
400 EXPECT_FALSE(window->HasCapture()); 448 EXPECT_FALSE(window->HasCapture());
401 449
402 // Do a capture. 450 // Do a capture.
403 window->SetCapture(); 451 window->SetCapture();
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 1369
1322 w3->Activate(); 1370 w3->Activate();
1323 EXPECT_EQ(w2.get(), active()); 1371 EXPECT_EQ(w2.get(), active());
1324 1372
1325 w1->Activate(); 1373 w1->Activate();
1326 EXPECT_EQ(w1.get(), active()); 1374 EXPECT_EQ(w1.get(), active());
1327 } 1375 }
1328 1376
1329 } // namespace test 1377 } // namespace test
1330 } // namespace aura 1378 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/gfx/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698