OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 window->RemoveObserver(this); | 1157 window->RemoveObserver(this); |
1158 if (window == owned_window_) { | 1158 if (window == owned_window_) { |
1159 owned_window_destroyed_ = true; | 1159 owned_window_destroyed_ = true; |
1160 } else if (window == top_level_widget_->GetNativeView()) { | 1160 } else if (window == top_level_widget_->GetNativeView()) { |
1161 owner_destroyed_ = true; | 1161 owner_destroyed_ = true; |
1162 } else { | 1162 } else { |
1163 ADD_FAILURE() << "Unexpected window destroyed callback: " << window; | 1163 ADD_FAILURE() << "Unexpected window destroyed callback: " << window; |
1164 } | 1164 } |
1165 } | 1165 } |
1166 | 1166 |
| 1167 aura::Window* owned_window() { |
| 1168 return owned_window_; |
| 1169 } |
| 1170 |
| 1171 views::Widget* top_level_widget() { |
| 1172 return top_level_widget_; |
| 1173 } |
| 1174 |
1167 private: | 1175 private: |
1168 views::Widget widget_; | 1176 views::Widget widget_; |
1169 views::Widget* top_level_widget_; | 1177 views::Widget* top_level_widget_; |
1170 aura::Window* owned_window_; | 1178 aura::Window* owned_window_; |
1171 bool owner_destroyed_; | 1179 bool owner_destroyed_; |
1172 bool owned_window_destroyed_; | 1180 bool owned_window_destroyed_; |
1173 aura::test::TestWindowDelegate child_window_delegate_; | 1181 aura::test::TestWindowDelegate child_window_delegate_; |
1174 | 1182 |
1175 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); | 1183 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); |
1176 }; | 1184 }; |
(...skipping 25 matching lines...) Expand all Loading... |
1202 ViewsDelegate::views_delegate = NULL; | 1210 ViewsDelegate::views_delegate = NULL; |
1203 DesktopAuraTopLevelWindowTest popup_window; | 1211 DesktopAuraTopLevelWindowTest popup_window; |
1204 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 1212 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
1205 gfx::Rect(0, 0, 200, 200), false)); | 1213 gfx::Rect(0, 0, 200, 200), false)); |
1206 | 1214 |
1207 RunPendingMessages(); | 1215 RunPendingMessages(); |
1208 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 1216 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
1209 RunPendingMessages(); | 1217 RunPendingMessages(); |
1210 } | 1218 } |
1211 | 1219 |
| 1220 #if defined(OS_WIN) |
| 1221 // TODO(ananta) |
| 1222 // Fix this test to work on Linux Aura. Need to implement the |
| 1223 // views::DesktopRootWindowHostX11::SetSize function |
| 1224 // This test validates that when a top level owned popup Aura window is |
| 1225 // resized, the widget is resized as well. |
| 1226 TEST_F(WidgetTest, DesktopAuraTopLevelOwnedPopupResizeTest) { |
| 1227 ViewsDelegate::views_delegate = NULL; |
| 1228 DesktopAuraTopLevelWindowTest popup_window; |
| 1229 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
| 1230 gfx::Rect(0, 0, 200, 200), false)); |
| 1231 |
| 1232 gfx::Rect new_size(0, 0, 400, 400); |
| 1233 popup_window.owned_window()->SetBounds(new_size); |
| 1234 |
| 1235 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), |
| 1236 new_size.size()); |
| 1237 RunPendingMessages(); |
| 1238 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
| 1239 RunPendingMessages(); |
| 1240 } |
| 1241 #endif |
| 1242 |
1212 // Test to ensure that the aura Window's visiblity state is set to visible if | 1243 // Test to ensure that the aura Window's visiblity state is set to visible if |
1213 // the underlying widget is hidden and then shown. | 1244 // the underlying widget is hidden and then shown. |
1214 TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { | 1245 TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { |
1215 // Create a widget. | 1246 // Create a widget. |
1216 Widget widget; | 1247 Widget widget; |
1217 Widget::InitParams init_params = | 1248 Widget::InitParams init_params = |
1218 CreateParams(Widget::InitParams::TYPE_WINDOW); | 1249 CreateParams(Widget::InitParams::TYPE_WINDOW); |
1219 init_params.show_state = ui::SHOW_STATE_NORMAL; | 1250 init_params.show_state = ui::SHOW_STATE_NORMAL; |
1220 gfx::Rect initial_bounds(0, 0, 300, 400); | 1251 gfx::Rect initial_bounds(0, 0, 300, 400); |
1221 init_params.bounds = initial_bounds; | 1252 init_params.bounds = initial_bounds; |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 EXPECT_EQ(activate_result, MA_ACTIVATE); | 2254 EXPECT_EQ(activate_result, MA_ACTIVATE); |
2224 | 2255 |
2225 modal_dialog_widget->CloseNow(); | 2256 modal_dialog_widget->CloseNow(); |
2226 top_level_widget.CloseNow(); | 2257 top_level_widget.CloseNow(); |
2227 } | 2258 } |
2228 #endif | 2259 #endif |
2229 #endif | 2260 #endif |
2230 | 2261 |
2231 } // namespace test | 2262 } // namespace test |
2232 } // namespace views | 2263 } // namespace views |
OLD | NEW |