OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "athena/screen/public/screen_manager.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "athena/test/athena_test_base.h" |
| 10 #include "ui/aura/window.h" |
| 11 |
| 12 typedef athena::test::AthenaTestBase ScreenManagerTest; |
| 13 |
| 14 namespace athena { |
| 15 namespace { |
| 16 |
| 17 aura::Window* Create(const std::string& name, int z_order_priority) { |
| 18 ScreenManager::ContainerParams params(name, z_order_priority); |
| 19 return ScreenManager::Get()->CreateContainer(params); |
| 20 } |
| 21 |
| 22 void CheckZOrder(aura::Window* w1, aura::Window* w2) { |
| 23 aura::Window* parent = w1->parent(); |
| 24 const aura::Window::Windows& children = parent->children(); |
| 25 aura::Window::Windows::const_iterator begin_iter = children.begin(); |
| 26 aura::Window::Windows::const_iterator end_iter = children.end(); |
| 27 |
| 28 aura::Window::Windows::const_iterator w1_iter = |
| 29 std::find(begin_iter, end_iter, w1); |
| 30 aura::Window::Windows::const_iterator w2_iter = |
| 31 std::find(begin_iter, end_iter, w2); |
| 32 EXPECT_NE(end_iter, w1_iter); |
| 33 EXPECT_NE(end_iter, w2_iter); |
| 34 EXPECT_TRUE(w1_iter < w2_iter); |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
| 39 TEST_F(ScreenManagerTest, Zorder) { |
| 40 aura::Window* window_10 = Create("test10", 10); |
| 41 aura::Window* window_11 = Create("test11", 11); |
| 42 aura::Window* window_12 = Create("test12", 12); |
| 43 |
| 44 { |
| 45 SCOPED_TRACE("Init"); |
| 46 CheckZOrder(window_10, window_11); |
| 47 CheckZOrder(window_11, window_12); |
| 48 } |
| 49 { |
| 50 SCOPED_TRACE("Delete"); |
| 51 delete window_11; |
| 52 CheckZOrder(window_10, window_12); |
| 53 } |
| 54 { |
| 55 SCOPED_TRACE("Insert"); |
| 56 window_11 = Create("test11", 11); |
| 57 CheckZOrder(window_10, window_11); |
| 58 CheckZOrder(window_11, window_12); |
| 59 } |
| 60 } |
| 61 |
| 62 } // namespace athena |
OLD | NEW |