diff options
Diffstat (limited to 'views/view_unittest.cc')
-rw-r--r-- | views/view_unittest.cc | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc index 16109f7..8207c76b 100644 --- a/views/view_unittest.cc +++ b/views/view_unittest.cc @@ -1439,22 +1439,33 @@ class TestChangeNativeViewHierarchy { view_test_->RunPendingMessages(); } - void CheckEnumeratingNativeWidgets() { - if (!host_->GetWindow()) + void CheckEnumeratingRootViews() { + std::vector<RootView*> enumerated_root_views; +#if defined(OS_WIN) + views::Widget::FindAllRootViews(host_->GetNativeView(), + &enumerated_root_views); +#else + // host_->GetNativeView() returns gfx::NativeView which is GtkWidget on + // systems other than Windows and views::Widget::FindAllRootViews() + // requires GtkWindow. + if (host_->GetWindow()) { + views::Widget::FindAllRootViews(host_->GetWindow()->GetNativeWindow(), + &enumerated_root_views); + } else { return; - NativeWidget::NativeWidgets widgets; - NativeWidget::GetAllNativeWidgets(host_->GetNativeView(), &widgets); - EXPECT_EQ(TestNativeViewHierarchy::kTotalViews + 1, widgets.size()); + } +#endif + EXPECT_EQ(TestNativeViewHierarchy::kTotalViews + 1, + enumerated_root_views.size()); // Unfortunately there is no guarantee the sequence of views here so always // go through all of them. - for (NativeWidget::NativeWidgets::iterator i = widgets.begin(); - i != widgets.end(); ++i) { - RootView* root_view = (*i)->GetWidget()->GetRootView(); - if (host_->GetRootView() == root_view) + for (std::vector<RootView*>::iterator i = enumerated_root_views.begin(); + i != enumerated_root_views.end(); ++i) { + if (host_->GetRootView() == *i) continue; size_t j; for (j = 0; j < TestNativeViewHierarchy::kTotalViews; ++j) - if (root_views_[j] == root_view) + if (root_views_[j] == *i) break; // EXPECT_LT/GT/GE() fails to compile with class-defined constants // with gcc, with error @@ -1498,7 +1509,7 @@ TEST_F(ViewTest, ChangeNativeViewHierarchyFindRoots) { // TODO(georgey): Fix the test for Linux #if defined(OS_WIN) TestChangeNativeViewHierarchy test(this); - test.CheckEnumeratingNativeWidgets(); + test.CheckEnumeratingRootViews(); #endif } |