Chromium Code Reviews| Index: athena/wm/window_list_provider_impl_unittest.cc |
| diff --git a/athena/wm/window_list_provider_impl_unittest.cc b/athena/wm/window_list_provider_impl_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..efa25c9a7f0a62f2c2ff884e64c90be632e4b87e |
| --- /dev/null |
| +++ b/athena/wm/window_list_provider_impl_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/wm/window_list_provider_impl.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "athena/test/athena_test_base.h" |
| +#include "ui/aura/test/test_window_delegate.h" |
| +#include "ui/aura/window.h" |
| + |
| +namespace athena { |
| + |
| +namespace { |
| + |
| +bool AreWindowListsEqual(const aura::Window::Windows& one, |
| + const aura::Window::Windows& two) { |
| + return one.size() == two.size() && |
| + std::equal(one.begin(), one.end(), two.begin()); |
| +} |
| + |
| +} // namespace |
| + |
| +typedef test::AthenaTestBase WindowListProviderImplTest; |
| + |
| +// Tests that the order of windows match the stacking order of the windows in |
| +// the container, even after the order is changed either through the aura Window |
| +// API or the WindowListProvider API. |
| +TEST_F(WindowListProviderImplTest, StackingOrder) { |
| + aura::test::TestWindowDelegate delegate; |
| + scoped_ptr<aura::Window> container(new aura::Window(&delegate)); |
| + scoped_ptr<aura::Window> first(new aura::Window(&delegate)); |
| + scoped_ptr<aura::Window> second(new aura::Window(&delegate)); |
| + scoped_ptr<aura::Window> third(new aura::Window(&delegate)); |
| + 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
|
| + second->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| + third->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| + first->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| + second->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| + third->Init(aura::WINDOW_LAYER_SOLID_COLOR); |
| + container->AddChild(first.get()); |
| + container->AddChild(second.get()); |
| + container->AddChild(third.get()); |
| + |
| + scoped_ptr<WindowListProvider> list_provider( |
| + new WindowListProviderImpl(container.get())); |
| + EXPECT_TRUE(AreWindowListsEqual(container->children(), |
| + list_provider->GetWindowList())); |
| + |
| + list_provider->MoveToFront(second.get()); |
| + EXPECT_TRUE(AreWindowListsEqual(container->children(), |
| + list_provider->GetWindowList())); |
| + EXPECT_EQ(second.get(), container->children().back()); |
| + |
| + container->StackChildAtTop(first.get()); |
| + EXPECT_TRUE(AreWindowListsEqual(container->children(), |
| + list_provider->GetWindowList())); |
| + EXPECT_EQ(first.get(), container->children().back()); |
| +} |
| + |
| +} // namespace athena |