diff options
Diffstat (limited to 'athena/screen/screen_manager_unittest.cc')
-rw-r--r-- | athena/screen/screen_manager_unittest.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/athena/screen/screen_manager_unittest.cc b/athena/screen/screen_manager_unittest.cc new file mode 100644 index 0000000..1a04ae8 --- /dev/null +++ b/athena/screen/screen_manager_unittest.cc @@ -0,0 +1,62 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "athena/screen/public/screen_manager.h" + +#include <string> + +#include "athena/test/athena_test_base.h" +#include "ui/aura/window.h" + +typedef athena::test::AthenaTestBase ScreenManagerTest; + +namespace athena { +namespace { + +aura::Window* Create(const std::string& name, int z_order_priority) { + ScreenManager::ContainerParams params(name, z_order_priority); + return ScreenManager::Get()->CreateContainer(params); +} + +void CheckZOrder(aura::Window* w1, aura::Window* w2) { + aura::Window* parent = w1->parent(); + const aura::Window::Windows& children = parent->children(); + aura::Window::Windows::const_iterator begin_iter = children.begin(); + aura::Window::Windows::const_iterator end_iter = children.end(); + + aura::Window::Windows::const_iterator w1_iter = + std::find(begin_iter, end_iter, w1); + aura::Window::Windows::const_iterator w2_iter = + std::find(begin_iter, end_iter, w2); + EXPECT_NE(end_iter, w1_iter); + EXPECT_NE(end_iter, w2_iter); + EXPECT_TRUE(w1_iter < w2_iter); +} + +} // namespace + +TEST_F(ScreenManagerTest, Zorder) { + aura::Window* window_10 = Create("test10", 10); + aura::Window* window_11 = Create("test11", 11); + aura::Window* window_12 = Create("test12", 12); + + { + SCOPED_TRACE("Init"); + CheckZOrder(window_10, window_11); + CheckZOrder(window_11, window_12); + } + { + SCOPED_TRACE("Delete"); + delete window_11; + CheckZOrder(window_10, window_12); + } + { + SCOPED_TRACE("Insert"); + window_11 = Create("test11", 11); + CheckZOrder(window_10, window_11); + CheckZOrder(window_11, window_12); + } +} + +} // namespace athena |