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

Side by Side Diff: ui/views/widget/native_widget_aura_unittest.cc

Issue 2542493002: Replace kCanMaximize/Minimize/Resize with kResizeBehavior. (Closed)
Patch Set: Fix int->bool compile issue. Created 4 years 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 | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/widget_delegate.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 (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 "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
15 #include "ui/aura/layout_manager.h" 16 #include "ui/aura/layout_manager.h"
16 #include "ui/aura/test/aura_test_base.h" 17 #include "ui/aura/test/aura_test_base.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_observer.h" 19 #include "ui/aura/window_observer.h"
19 #include "ui/aura/window_tree_host.h" 20 #include "ui/aura/window_tree_host.h"
20 #include "ui/events/event.h" 21 #include "ui/events/event.h"
21 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 class PropertyTestLayoutManager : public TestLayoutManagerBase { 302 class PropertyTestLayoutManager : public TestLayoutManagerBase {
302 public: 303 public:
303 PropertyTestLayoutManager() : added_(false) {} 304 PropertyTestLayoutManager() : added_(false) {}
304 ~PropertyTestLayoutManager() override {} 305 ~PropertyTestLayoutManager() override {}
305 306
306 bool added() const { return added_; } 307 bool added() const { return added_; }
307 308
308 private: 309 private:
309 // aura::LayoutManager: 310 // aura::LayoutManager:
310 void OnWindowAddedToLayout(aura::Window* child) override { 311 void OnWindowAddedToLayout(aura::Window* child) override {
311 EXPECT_TRUE(child->GetProperty(aura::client::kCanMaximizeKey)); 312 EXPECT_EQ(ui::mojom::kResizeBehaviorCanResize |
312 EXPECT_TRUE(child->GetProperty(aura::client::kCanMinimizeKey)); 313 ui::mojom::kResizeBehaviorCanMaximize |
313 EXPECT_TRUE(child->GetProperty(aura::client::kCanResizeKey)); 314 ui::mojom::kResizeBehaviorCanMinimize,
315 child->GetProperty(aura::client::kResizeBehaviorKey));
314 added_ = true; 316 added_ = true;
315 } 317 }
316 318
317 bool added_; 319 bool added_;
318 320
319 DISALLOW_COPY_AND_ASSIGN(PropertyTestLayoutManager); 321 DISALLOW_COPY_AND_ASSIGN(PropertyTestLayoutManager);
320 }; 322 };
321 323
322 class PropertyTestWidgetDelegate : public views::WidgetDelegate { 324 class PropertyTestWidgetDelegate : public views::WidgetDelegate {
323 public: 325 public:
324 explicit PropertyTestWidgetDelegate(Widget* widget) : widget_(widget) {} 326 explicit PropertyTestWidgetDelegate(Widget* widget) : widget_(widget) {}
325 ~PropertyTestWidgetDelegate() override {} 327 ~PropertyTestWidgetDelegate() override {}
326 328
327 private: 329 private:
328 // views::WidgetDelegate: 330 // views::WidgetDelegate:
329 bool CanMaximize() const override { return true; } 331 bool CanMaximize() const override { return true; }
330 bool CanMinimize() const override { return true; } 332 bool CanMinimize() const override { return true; }
331 bool CanResize() const override { return true; } 333 bool CanResize() const override { return true; }
332 void DeleteDelegate() override { delete this; } 334 void DeleteDelegate() override { delete this; }
333 Widget* GetWidget() override { return widget_; } 335 Widget* GetWidget() override { return widget_; }
334 const Widget* GetWidget() const override { return widget_; } 336 const Widget* GetWidget() const override { return widget_; }
335 337
336 Widget* widget_; 338 Widget* widget_;
337 DISALLOW_COPY_AND_ASSIGN(PropertyTestWidgetDelegate); 339 DISALLOW_COPY_AND_ASSIGN(PropertyTestWidgetDelegate);
338 }; 340 };
339 341
340 // Verifies that the kCanMaximizeKey/kCanMinimizeKey/kCanResizeKey have the 342 // Verifies the resize behavior when added to the layout manager.
341 // correct value when added to the layout manager.
342 TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) { 343 TEST_F(NativeWidgetAuraTest, TestPropertiesWhenAddedToLayout) {
343 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480)); 344 root_window()->SetBounds(gfx::Rect(0, 0, 640, 480));
344 PropertyTestLayoutManager* layout_manager = new PropertyTestLayoutManager(); 345 PropertyTestLayoutManager* layout_manager = new PropertyTestLayoutManager();
345 root_window()->SetLayoutManager(layout_manager); 346 root_window()->SetLayoutManager(layout_manager);
346 std::unique_ptr<TestWidget> widget(new TestWidget()); 347 std::unique_ptr<TestWidget> widget(new TestWidget());
347 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); 348 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
348 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 349 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
349 params.delegate = new PropertyTestWidgetDelegate(widget.get()); 350 params.delegate = new PropertyTestWidgetDelegate(widget.get());
350 params.parent = nullptr; 351 params.parent = nullptr;
351 params.context = root_window(); 352 params.context = root_window();
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 EXPECT_FALSE(delegate.view()->HasFocus()); 597 EXPECT_FALSE(delegate.view()->HasFocus());
597 598
598 test_focus_rules()->set_can_activate(true); 599 test_focus_rules()->set_can_activate(true);
599 views::test::TestInitialFocusWidgetDelegate delegate2(root_window()); 600 views::test::TestInitialFocusWidgetDelegate delegate2(root_window());
600 delegate2.GetWidget()->Show(); 601 delegate2.GetWidget()->Show();
601 EXPECT_TRUE(delegate2.view()->HasFocus()); 602 EXPECT_TRUE(delegate2.view()->HasFocus());
602 } 603 }
603 604
604 } // namespace 605 } // namespace
605 } // namespace views 606 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/widget/widget_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698