Chromium Code Reviews| 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/wm/window_list_provider_impl.h" | |
| 6 | |
| 7 #include <algorithm> | |
| 8 | |
| 9 #include "athena/test/athena_test_base.h" | |
| 10 #include "ui/aura/test/test_window_delegate.h" | |
| 11 #include "ui/aura/window.h" | |
| 12 | |
| 13 namespace athena { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 bool AreWindowListsEqual(const aura::Window::Windows& one, | |
| 18 const aura::Window::Windows& two) { | |
| 19 return one.size() == two.size() && | |
| 20 std::equal(one.begin(), one.end(), two.begin()); | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 typedef test::AthenaTestBase WindowListProviderImplTest; | |
| 26 | |
| 27 // Tests that the order of windows match the stacking order of the windows in | |
| 28 // the container, even after the order is changed either through the aura Window | |
| 29 // API or the WindowListProvider API. | |
| 30 TEST_F(WindowListProviderImplTest, StackingOrder) { | |
| 31 aura::test::TestWindowDelegate delegate; | |
| 32 scoped_ptr<aura::Window> container(new aura::Window(&delegate)); | |
| 33 scoped_ptr<aura::Window> first(new aura::Window(&delegate)); | |
| 34 scoped_ptr<aura::Window> second(new aura::Window(&delegate)); | |
| 35 scoped_ptr<aura::Window> third(new aura::Window(&delegate)); | |
| 36 first->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
|
mfomitchev
2014/08/14 21:58:54
Would be good to add a non-normal window to the mi
sadrul
2014/08/14 23:47:22
I have added a separate test that makes sure that
| |
| 37 second->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
| 38 third->SetType(ui::wm::WINDOW_TYPE_NORMAL); | |
| 39 first->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
| 40 second->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
| 41 third->Init(aura::WINDOW_LAYER_SOLID_COLOR); | |
| 42 container->AddChild(first.get()); | |
| 43 container->AddChild(second.get()); | |
| 44 container->AddChild(third.get()); | |
| 45 | |
| 46 scoped_ptr<WindowListProvider> list_provider( | |
| 47 new WindowListProviderImpl(container.get())); | |
| 48 EXPECT_TRUE(AreWindowListsEqual(container->children(), | |
| 49 list_provider->GetWindowList())); | |
| 50 | |
| 51 list_provider->MoveToFront(second.get()); | |
| 52 EXPECT_TRUE(AreWindowListsEqual(container->children(), | |
| 53 list_provider->GetWindowList())); | |
| 54 EXPECT_EQ(second.get(), container->children().back()); | |
| 55 | |
| 56 container->StackChildAtTop(first.get()); | |
| 57 EXPECT_TRUE(AreWindowListsEqual(container->children(), | |
| 58 list_provider->GetWindowList())); | |
| 59 EXPECT_EQ(first.get(), container->children().back()); | |
| 60 } | |
| 61 | |
| 62 } // namespace athena | |
| OLD | NEW |