Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: ui/views/cocoa/bridged_native_widget_unittest.mm

Issue 2228593002: Implement Harmony textfield border (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tapted to the resuce Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/controls/focusable_border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #import "base/mac/foundation_util.h" 11 #import "base/mac/foundation_util.h"
12 #import "base/mac/mac_util.h" 12 #import "base/mac/mac_util.h"
13 #import "base/mac/sdk_forward_declarations.h" 13 #import "base/mac/sdk_forward_declarations.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #import "testing/gtest_mac.h" 19 #import "testing/gtest_mac.h"
20 #import "ui/base/cocoa/window_size_constants.h" 20 #import "ui/base/cocoa/window_size_constants.h"
21 #include "ui/base/ime/input_method.h" 21 #include "ui/base/ime/input_method.h"
22 #include "ui/base/material_design/material_design_controller.h"
23 #include "ui/base/test/material_design_controller_test_api.h"
22 #include "ui/events/test/cocoa_test_event_utils.h" 24 #include "ui/events/test/cocoa_test_event_utils.h"
23 #import "ui/gfx/mac/coordinate_conversion.h" 25 #import "ui/gfx/mac/coordinate_conversion.h"
24 #import "ui/gfx/test/ui_cocoa_test_helper.h" 26 #import "ui/gfx/test/ui_cocoa_test_helper.h"
25 #import "ui/views/cocoa/bridged_content_view.h" 27 #import "ui/views/cocoa/bridged_content_view.h"
26 #import "ui/views/cocoa/native_widget_mac_nswindow.h" 28 #import "ui/views/cocoa/native_widget_mac_nswindow.h"
27 #import "ui/views/cocoa/views_nswindow_delegate.h" 29 #import "ui/views/cocoa/views_nswindow_delegate.h"
28 #include "ui/views/controls/textfield/textfield.h" 30 #include "ui/views/controls/textfield/textfield.h"
29 #include "ui/views/controls/textfield/textfield_model.h" 31 #include "ui/views/controls/textfield/textfield_model.h"
30 #include "ui/views/view.h" 32 #include "ui/views/view.h"
31 #include "ui/views/widget/native_widget_mac.h" 33 #include "ui/views/widget/native_widget_mac.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 native_widget_mac_(new MockNativeWidgetMac(widget_.get())) { 234 native_widget_mac_(new MockNativeWidgetMac(widget_.get())) {
233 } 235 }
234 236
235 std::unique_ptr<BridgedNativeWidget>& bridge() { 237 std::unique_ptr<BridgedNativeWidget>& bridge() {
236 return native_widget_mac_->bridge(); 238 return native_widget_mac_->bridge();
237 } 239 }
238 240
239 // Overridden from testing::Test: 241 // Overridden from testing::Test:
240 void SetUp() override { 242 void SetUp() override {
241 ui::CocoaTest::SetUp(); 243 ui::CocoaTest::SetUp();
244 ui::MaterialDesignController::Initialize();
242 245
243 init_params_.native_widget = native_widget_mac_; 246 init_params_.native_widget = native_widget_mac_;
244 247
245 // Use a frameless window, otherwise Widget will try to center the window 248 // Use a frameless window, otherwise Widget will try to center the window
246 // before the tests covering the Init() flow are ready to do that. 249 // before the tests covering the Init() flow are ready to do that.
247 init_params_.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS; 250 init_params_.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS;
248 251
249 // To control the lifetime without an actual window that must be closed, 252 // To control the lifetime without an actual window that must be closed,
250 // tests in this file need to use WIDGET_OWNS_NATIVE_WIDGET. 253 // tests in this file need to use WIDGET_OWNS_NATIVE_WIDGET.
251 init_params_.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 254 init_params_.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
252 255
253 // Opacity defaults to "infer" which is usually updated by ViewsDelegate. 256 // Opacity defaults to "infer" which is usually updated by ViewsDelegate.
254 init_params_.opacity = Widget::InitParams::OPAQUE_WINDOW; 257 init_params_.opacity = Widget::InitParams::OPAQUE_WINDOW;
255 258
256 init_params_.bounds = gfx::Rect(100, 100, 100, 100); 259 init_params_.bounds = gfx::Rect(100, 100, 100, 100);
257 260
258 native_widget_mac_->GetWidget()->Init(init_params_); 261 native_widget_mac_->GetWidget()->Init(init_params_);
259 } 262 }
260 263
264 void TearDown() override {
265 ui::test::MaterialDesignControllerTestAPI::Uninitialize();
266 ui::CocoaTest::TearDown();
267 }
268
261 protected: 269 protected:
262 std::unique_ptr<Widget> widget_; 270 std::unique_ptr<Widget> widget_;
263 MockNativeWidgetMac* native_widget_mac_; // Weak. Owned by |widget_|. 271 MockNativeWidgetMac* native_widget_mac_; // Weak. Owned by |widget_|.
264 272
265 // Make the InitParams available to tests to cover initialization codepaths. 273 // Make the InitParams available to tests to cover initialization codepaths.
266 Widget::InitParams init_params_; 274 Widget::InitParams init_params_;
267 }; 275 };
268 276
269 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase { 277 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase {
270 public: 278 public:
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 [center postNotificationName:NSWindowDidExitFullScreenNotification 1297 [center postNotificationName:NSWindowDidExitFullScreenNotification
1290 object:window]; 1298 object:window];
1291 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. 1299 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change.
1292 EXPECT_FALSE(bridge()->target_fullscreen_state()); 1300 EXPECT_FALSE(bridge()->target_fullscreen_state());
1293 1301
1294 widget_->CloseNow(); 1302 widget_->CloseNow();
1295 } 1303 }
1296 1304
1297 } // namespace test 1305 } // namespace test
1298 } // namespace views 1306 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/focusable_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698