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 | |
1175 private: | 1167 private: |
1176 views::Widget widget_; | 1168 views::Widget widget_; |
1177 views::Widget* top_level_widget_; | 1169 views::Widget* top_level_widget_; |
1178 aura::Window* owned_window_; | 1170 aura::Window* owned_window_; |
1179 bool owner_destroyed_; | 1171 bool owner_destroyed_; |
1180 bool owned_window_destroyed_; | 1172 bool owned_window_destroyed_; |
1181 aura::test::TestWindowDelegate child_window_delegate_; | 1173 aura::test::TestWindowDelegate child_window_delegate_; |
1182 | 1174 |
1183 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); | 1175 DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); |
1184 }; | 1176 }; |
(...skipping 25 matching lines...) Expand all Loading... |
1210 ViewsDelegate::views_delegate = NULL; | 1202 ViewsDelegate::views_delegate = NULL; |
1211 DesktopAuraTopLevelWindowTest popup_window; | 1203 DesktopAuraTopLevelWindowTest popup_window; |
1212 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | 1204 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( |
1213 gfx::Rect(0, 0, 200, 200), false)); | 1205 gfx::Rect(0, 0, 200, 200), false)); |
1214 | 1206 |
1215 RunPendingMessages(); | 1207 RunPendingMessages(); |
1216 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | 1208 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); |
1217 RunPendingMessages(); | 1209 RunPendingMessages(); |
1218 } | 1210 } |
1219 | 1211 |
1220 // This test validates that when a top level owned popup Aura window is | |
1221 // resized, the widget is resized as well. | |
1222 TEST_F(WidgetTest, DesktopAuraTopLevelOwnedPopupResizeTest) { | |
1223 ViewsDelegate::views_delegate = NULL; | |
1224 DesktopAuraTopLevelWindowTest popup_window; | |
1225 ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( | |
1226 gfx::Rect(0, 0, 200, 200), false)); | |
1227 | |
1228 gfx::Rect new_size(0, 0, 400, 400); | |
1229 popup_window.owned_window()->SetBounds(new_size); | |
1230 | |
1231 EXPECT_EQ(popup_window.top_level_widget()->GetNativeView()->bounds().size(), | |
1232 new_size.size()); | |
1233 RunPendingMessages(); | |
1234 ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); | |
1235 RunPendingMessages(); | |
1236 } | |
1237 | |
1238 // Test to ensure that the aura Window's visiblity state is set to visible if | 1212 // Test to ensure that the aura Window's visiblity state is set to visible if |
1239 // the underlying widget is hidden and then shown. | 1213 // the underlying widget is hidden and then shown. |
1240 TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { | 1214 TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { |
1241 // Create a widget. | 1215 // Create a widget. |
1242 Widget widget; | 1216 Widget widget; |
1243 Widget::InitParams init_params = | 1217 Widget::InitParams init_params = |
1244 CreateParams(Widget::InitParams::TYPE_WINDOW); | 1218 CreateParams(Widget::InitParams::TYPE_WINDOW); |
1245 init_params.show_state = ui::SHOW_STATE_NORMAL; | 1219 init_params.show_state = ui::SHOW_STATE_NORMAL; |
1246 gfx::Rect initial_bounds(0, 0, 300, 400); | 1220 gfx::Rect initial_bounds(0, 0, 300, 400); |
1247 init_params.bounds = initial_bounds; | 1221 init_params.bounds = initial_bounds; |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 EXPECT_EQ(activate_result, MA_ACTIVATE); | 2223 EXPECT_EQ(activate_result, MA_ACTIVATE); |
2250 | 2224 |
2251 modal_dialog_widget->CloseNow(); | 2225 modal_dialog_widget->CloseNow(); |
2252 top_level_widget.CloseNow(); | 2226 top_level_widget.CloseNow(); |
2253 } | 2227 } |
2254 #endif | 2228 #endif |
2255 #endif | 2229 #endif |
2256 | 2230 |
2257 } // namespace test | 2231 } // namespace test |
2258 } // namespace views | 2232 } // namespace views |
OLD | NEW |