diff options
Diffstat (limited to 'ui/aura/test')
-rw-r--r-- | ui/aura/test/test_windows.cc | 30 | ||||
-rw-r--r-- | ui/aura/test/test_windows.h | 10 |
2 files changed, 40 insertions, 0 deletions
diff --git a/ui/aura/test/test_windows.cc b/ui/aura/test/test_windows.cc index 1c8a540..14fd638 100644 --- a/ui/aura/test/test_windows.cc +++ b/ui/aura/test/test_windows.cc @@ -54,5 +54,35 @@ Window* CreateTestWindowWithDelegateAndType(WindowDelegate* delegate, return window; } +Window* CreateTransientChild(int id, Window* parent) { + Window* window = new Window(NULL); + window->set_id(id); + window->SetType(aura::client::WINDOW_TYPE_NORMAL); + window->Init(ui::Layer::LAYER_TEXTURED); + window->SetParent(NULL); + parent->AddTransientChild(window); + return window; +} + +template <typename T> +bool ObjectIsAbove(T* upper, T* lower) { + DCHECK_EQ(upper->parent(), lower->parent()); + DCHECK_NE(upper, lower); + const std::vector<T*>& children = upper->parent()->children(); + const size_t upper_i = + std::find(children.begin(), children.end(), upper) - children.begin(); + const size_t lower_i = + std::find(children.begin(), children.end(), lower) - children.begin(); + return upper_i > lower_i; +} + +bool WindowIsAbove(Window* upper, Window* lower) { + return ObjectIsAbove<Window>(upper, lower); +} + +bool LayerIsAbove(Window* upper, Window* lower) { + return ObjectIsAbove<ui::Layer>(upper->layer(), lower->layer()); +} + } // namespace test } // namespace aura diff --git a/ui/aura/test/test_windows.h b/ui/aura/test/test_windows.h index 1781104..d0b782d 100644 --- a/ui/aura/test/test_windows.h +++ b/ui/aura/test/test_windows.h @@ -31,6 +31,16 @@ Window* CreateTestWindowWithDelegateAndType(WindowDelegate* delegate, const gfx::Rect& bounds, Window* parent); +// Creates a transient child window of |parent|. +Window* CreateTransientChild(int id, Window* parent); + +// Returns true if |upper| is above |lower| in the window stacking order. +bool WindowIsAbove(Window* upper, Window* lower); + +// Returns true if |upper|'s layer is above |lower|'s layer in the layer +// stacking order. +bool LayerIsAbove(Window* upper, Window* lower); + } // namespace test } // namespace aura |