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

Side by Side Diff: ui/views/test/widget_test_aura.cc

Issue 831643004: MacViews: Fix child window z-order and SetBounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CHECK->EXPECT_TRUE Created 5 years, 11 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
« no previous file with comments | « ui/views/test/widget_test.h ('k') | ui/views/test/widget_test_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/test/widget_test.h" 5 #include "ui/views/test/widget_test.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 #include "ui/aura/window_tree_host.h" 8 #include "ui/aura/window_tree_host.h"
9 #include "ui/views/widget/widget.h" 9 #include "ui/views/widget/widget.h"
10 10
11 namespace views { 11 namespace views {
12 namespace test { 12 namespace test {
13 13
14 namespace {
15
16 // Perform a pre-order traversal of |children| and all descendants, looking for
17 // |first| and |second|. If |first| is found before |second|, return true.
18 // When a layer is found, it is set to null. Returns once |second| is found, or
19 // when there are no children left.
20 // Note that ui::Layer children are bottom-to-top stacking order.
21 bool FindLayersInOrder(const std::vector<ui::Layer*>& children,
22 const ui::Layer** first,
23 const ui::Layer** second) {
24 for (const ui::Layer* child : children) {
25 if (child == *second) {
26 *second = nullptr;
27 return *first == nullptr;
28 }
29
30 if (child == *first)
31 *first = nullptr;
32
33 if (FindLayersInOrder(child->children(), first, second))
34 return true;
35
36 // If second is cleared without success, exit early with failure.
37 if (!*second)
38 return false;
39 }
40 return false;
41 }
42
43 } // namespace
44
14 // static 45 // static
15 void WidgetTest::SimulateNativeDestroy(Widget* widget) { 46 void WidgetTest::SimulateNativeDestroy(Widget* widget) {
16 delete widget->GetNativeView(); 47 delete widget->GetNativeView();
17 } 48 }
18 49
19 // static 50 // static
20 bool WidgetTest::IsNativeWindowVisible(gfx::NativeWindow window) { 51 bool WidgetTest::IsNativeWindowVisible(gfx::NativeWindow window) {
21 return window->IsVisible(); 52 return window->IsVisible();
22 } 53 }
23 54
24 // static 55 // static
56 bool WidgetTest::IsWindowStackedAbove(Widget* above, Widget* below) {
57 EXPECT_TRUE(above->IsVisible());
58 EXPECT_TRUE(below->IsVisible());
59
60 ui::Layer* root_layer = above->GetNativeWindow()->GetRootWindow()->layer();
61
62 // Traversal is bottom-to-top, so |below| should be found first.
63 const ui::Layer* first = below->GetLayer();
64 const ui::Layer* second = above->GetLayer();
65 return FindLayersInOrder(root_layer->children(), &first, &second);
66 }
67
68 // static
25 ui::EventProcessor* WidgetTest::GetEventProcessor(Widget* widget) { 69 ui::EventProcessor* WidgetTest::GetEventProcessor(Widget* widget) {
26 return widget->GetNativeWindow()->GetHost()->event_processor(); 70 return widget->GetNativeWindow()->GetHost()->event_processor();
27 } 71 }
28 72
29 } // namespace test 73 } // namespace test
30 } // namespace views 74 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/test/widget_test.h ('k') | ui/views/test/widget_test_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698