| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel)); | 1165 EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel)); |
| 1166 | 1166 |
| 1167 // And it stays maximized after getting out of full screen. | 1167 // And it stays maximized after getting out of full screen. |
| 1168 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel)); | 1168 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel)); |
| 1169 | 1169 |
| 1170 // Clean up. | 1170 // Clean up. |
| 1171 toplevel->Close(); | 1171 toplevel->Close(); |
| 1172 RunPendingMessages(); | 1172 RunPendingMessages(); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 // Testing widget delegate that creates a widget with a single view, which | |
| 1176 // should be initially focused. | |
| 1177 class TestInitialFocusWidgetDelegate : public TestDesktopWidgetDelegate { | |
| 1178 public: | |
| 1179 explicit TestInitialFocusWidgetDelegate(gfx::NativeWindow context) | |
| 1180 : view_(new View) { | |
| 1181 view_->SetFocusable(true); | |
| 1182 | |
| 1183 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | |
| 1184 params.context = context; | |
| 1185 InitWidget(params); | |
| 1186 GetWidget()->GetContentsView()->AddChildView(view_); | |
| 1187 } | |
| 1188 | |
| 1189 View* view() { return view_; } | |
| 1190 | |
| 1191 // DialogDelegateView: | |
| 1192 View* GetInitiallyFocusedView() override { return view_; } | |
| 1193 | |
| 1194 private: | |
| 1195 View* view_; | |
| 1196 | |
| 1197 DISALLOW_COPY_AND_ASSIGN(TestInitialFocusWidgetDelegate); | |
| 1198 }; | |
| 1199 | |
| 1200 // Testing initial focus is assigned properly for normal top-level widgets, | 1175 // Testing initial focus is assigned properly for normal top-level widgets, |
| 1201 // and subclasses that specify a initially focused child view. | 1176 // and subclasses that specify a initially focused child view. |
| 1202 TEST_F(WidgetTestInteractive, InitialFocus) { | 1177 TEST_F(WidgetTestInteractive, InitialFocus) { |
| 1203 // By default, there is no initially focused view (even if there is a | 1178 // By default, there is no initially focused view (even if there is a |
| 1204 // focusable subview). | 1179 // focusable subview). |
| 1205 Widget* toplevel(CreateTopLevelPlatformWidget()); | 1180 Widget* toplevel(CreateTopLevelPlatformWidget()); |
| 1206 View* view = new View; | 1181 View* view = new View; |
| 1207 view->SetFocusable(true); | 1182 view->SetFocusable(true); |
| 1208 toplevel->GetContentsView()->AddChildView(view); | 1183 toplevel->GetContentsView()->AddChildView(view); |
| 1209 | 1184 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 | 1707 |
| 1733 ui::KeyEvent key_event2(key_event); | 1708 ui::KeyEvent key_event2(key_event); |
| 1734 widget->OnKeyEvent(&key_event2); | 1709 widget->OnKeyEvent(&key_event2); |
| 1735 EXPECT_FALSE(key_event2.stopped_propagation()); | 1710 EXPECT_FALSE(key_event2.stopped_propagation()); |
| 1736 | 1711 |
| 1737 widget->CloseNow(); | 1712 widget->CloseNow(); |
| 1738 } | 1713 } |
| 1739 | 1714 |
| 1740 } // namespace test | 1715 } // namespace test |
| 1741 } // namespace views | 1716 } // namespace views |
| OLD | NEW |