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

Unified 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: ShowInactive for a more compelling test 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/test/widget_test_aura.cc
diff --git a/ui/views/test/widget_test_aura.cc b/ui/views/test/widget_test_aura.cc
index 1b2dd139fc10fc2c06caee0c9f3b0847fcfd0462..e73c8c74cacfb2f77d414ca5e07db2079b1f9b68 100644
--- a/ui/views/test/widget_test_aura.cc
+++ b/ui/views/test/widget_test_aura.cc
@@ -11,6 +11,37 @@
namespace views {
namespace test {
+namespace {
+
+// Perform a pre-order traversal of |children| and all descendants, looking for
+// |first| and |second|. If |first| is found before |second|, return true.
+// When a layer is found, it is set to null. Returns once |second| is found, or
+// when there are no children left.
+// Note than ui::Layer children are bottom-to-top stacking order.
+bool FindLayersInOrder(const std::vector<ui::Layer*>& children,
Robert Sesek 2015/01/07 00:11:40 This function is not easy to reason about, but I d
tapted 2015/01/07 01:44:12 Yeah - I felt bad putting recursion in a test func
+ const ui::Layer** first,
+ const ui::Layer** second) {
+ for (const ui::Layer* child : children) {
+ if (child == *second) {
+ *second = nullptr;
+ return *first == nullptr;
+ }
+
+ if (child == *first)
+ *first = nullptr;
+
+ if (FindLayersInOrder(child->children(), first, second))
+ return true;
+
+ // If second is cleared without success, exit early with failure.
+ if (!*second)
+ return false;
+ }
+ return false;
+}
+
+} // namespace
+
// static
void WidgetTest::SimulateNativeDestroy(Widget* widget) {
delete widget->GetNativeView();
@@ -22,6 +53,19 @@ bool WidgetTest::IsNativeWindowVisible(gfx::NativeWindow window) {
}
// static
+bool WidgetTest::IsWindowStackedAbove(Widget* above, Widget* below) {
+ CHECK(above->IsVisible());
+ CHECK(below->IsVisible());
+
+ ui::Layer* root_layer = above->GetNativeWindow()->GetRootWindow()->layer();
+
+ // Traversal is bottom-to-top, so |below| should be found first.
+ const ui::Layer* first = below->GetLayer();
+ const ui::Layer* second = above->GetLayer();
+ return FindLayersInOrder(root_layer->children(), &first, &second);
+}
+
+// static
ui::EventProcessor* WidgetTest::GetEventProcessor(Widget* widget) {
return widget->GetNativeWindow()->GetHost()->event_processor();
}
« 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