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

Side by Side Diff: athena/wm/window_list_provider_impl_unittest.cc

Issue 470083004: athena: A simpler implementation of WindowListProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months 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 | « athena/wm/window_list_provider_impl.cc ('k') | athena/wm/window_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate,
24 ui::wm::WindowType window_type) {
25 scoped_ptr<aura::Window> window(new aura::Window(delegate));
26 window->SetType(window_type);
27 window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
28 return window.Pass();
29 }
30
31 } // namespace
32
33 typedef test::AthenaTestBase WindowListProviderImplTest;
34
35 // Tests that the order of windows match the stacking order of the windows in
36 // the container, even after the order is changed through the aura Window API.
37 TEST_F(WindowListProviderImplTest, StackingOrder) {
38 aura::test::TestWindowDelegate delegate;
39 scoped_ptr<aura::Window> container(new aura::Window(&delegate));
40 scoped_ptr<aura::Window> first =
41 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_NORMAL);
42 scoped_ptr<aura::Window> second =
43 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_NORMAL);
44 scoped_ptr<aura::Window> third =
45 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_NORMAL);
46 container->AddChild(first.get());
47 container->AddChild(second.get());
48 container->AddChild(third.get());
49
50 scoped_ptr<WindowListProvider> list_provider(
51 new WindowListProviderImpl(container.get()));
52 EXPECT_TRUE(AreWindowListsEqual(container->children(),
53 list_provider->GetWindowList()));
54
55 container->StackChildAtTop(first.get());
56 EXPECT_TRUE(AreWindowListsEqual(container->children(),
57 list_provider->GetWindowList()));
58 EXPECT_EQ(first.get(), container->children().back());
59 }
60
61 TEST_F(WindowListProviderImplTest, ListContainsOnlyNormalWindows) {
62 aura::test::TestWindowDelegate delegate;
63 scoped_ptr<aura::Window> container(new aura::Window(&delegate));
64 scoped_ptr<aura::Window> first =
65 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_NORMAL);
66 scoped_ptr<aura::Window> second =
67 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_POPUP);
68 scoped_ptr<aura::Window> third =
69 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_NORMAL);
70 scoped_ptr<aura::Window> fourth =
71 CreateWindow(&delegate, ui::wm::WINDOW_TYPE_MENU);
72 container->AddChild(first.get());
73 container->AddChild(second.get());
74 container->AddChild(third.get());
75 container->AddChild(fourth.get());
76
77 scoped_ptr<WindowListProvider> list_provider(
78 new WindowListProviderImpl(container.get()));
79 const aura::Window::Windows list = list_provider->GetWindowList();
80 EXPECT_EQ(list.end(), std::find(list.begin(), list.end(), second.get()));
81 EXPECT_EQ(list.end(), std::find(list.begin(), list.end(), fourth.get()));
82 EXPECT_NE(list.end(), std::find(list.begin(), list.end(), first.get()));
83 EXPECT_NE(list.end(), std::find(list.begin(), list.end(), third.get()));
84 }
85
86 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/window_list_provider_impl.cc ('k') | athena/wm/window_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698