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

Side by Side Diff: ui/message_center/views/custom_notification_view_unittest.cc

Issue 2889623002: Apply View::set_preferred_size in some more places. (Closed)
Patch Set: fix SystemMenuButton Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 16 matching lines...) Expand all
27 27
28 namespace { 28 namespace {
29 29
30 const SkColor kBackgroundColor = SK_ColorGREEN; 30 const SkColor kBackgroundColor = SK_ColorGREEN;
31 31
32 class TestCustomView : public views::View { 32 class TestCustomView : public views::View {
33 public: 33 public:
34 TestCustomView() { 34 TestCustomView() {
35 SetFocusBehavior(FocusBehavior::ALWAYS); 35 SetFocusBehavior(FocusBehavior::ALWAYS);
36 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); 36 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
37 set_preferred_size(gfx::Size(100, 100));
37 } 38 }
38 ~TestCustomView() override {} 39 ~TestCustomView() override {}
39 40
40 void Reset() { 41 void Reset() {
41 mouse_event_count_ = 0; 42 mouse_event_count_ = 0;
42 keyboard_event_count_ = 0; 43 keyboard_event_count_ = 0;
43 } 44 }
44 45
45 void set_preferred_size(gfx::Size size) { preferred_size_ = size; }
46
47 // views::View 46 // views::View
48 gfx::Size GetPreferredSize() const override { return preferred_size_; }
49 bool OnMousePressed(const ui::MouseEvent& event) override { 47 bool OnMousePressed(const ui::MouseEvent& event) override {
50 ++mouse_event_count_; 48 ++mouse_event_count_;
51 return true; 49 return true;
52 } 50 }
53 void OnMouseMoved(const ui::MouseEvent& event) override { 51 void OnMouseMoved(const ui::MouseEvent& event) override {
54 ++mouse_event_count_; 52 ++mouse_event_count_;
55 } 53 }
56 void OnMouseReleased(const ui::MouseEvent& event) override { 54 void OnMouseReleased(const ui::MouseEvent& event) override {
57 ++mouse_event_count_; 55 ++mouse_event_count_;
58 } 56 }
59 bool OnKeyPressed(const ui::KeyEvent& event) override { 57 bool OnKeyPressed(const ui::KeyEvent& event) override {
60 ++keyboard_event_count_; 58 ++keyboard_event_count_;
61 return false; 59 return false;
62 } 60 }
63 61
64 int mouse_event_count() const { return mouse_event_count_; } 62 int mouse_event_count() const { return mouse_event_count_; }
65 int keyboard_event_count() const { return keyboard_event_count_; } 63 int keyboard_event_count() const { return keyboard_event_count_; }
66 64
67 private: 65 private:
68 int mouse_event_count_ = 0; 66 int mouse_event_count_ = 0;
69 int keyboard_event_count_ = 0; 67 int keyboard_event_count_ = 0;
70 gfx::Size preferred_size_ = gfx::Size(100, 100);
71 68
72 DISALLOW_COPY_AND_ASSIGN(TestCustomView); 69 DISALLOW_COPY_AND_ASSIGN(TestCustomView);
73 }; 70 };
74 71
75 class TestContentViewDelegate : public CustomNotificationContentViewDelegate { 72 class TestContentViewDelegate : public CustomNotificationContentViewDelegate {
76 public: 73 public:
77 bool IsCloseButtonFocused() const override { return false; } 74 bool IsCloseButtonFocused() const override { return false; }
78 void RequestFocusOnCloseButton() override {} 75 void RequestFocusOnCloseButton() override {}
79 void UpdateControlButtonsVisibility() override {} 76 void UpdateControlButtonsVisibility() override {}
80 }; 77 };
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 EXPECT_EQ("360x10", size.ToString()); 321 EXPECT_EQ("360x10", size.ToString());
325 322
326 // The long notification. 323 // The long notification.
327 custom_view()->set_preferred_size(gfx::Size(1000, 1000)); 324 custom_view()->set_preferred_size(gfx::Size(1000, 1000));
328 size = notification_view()->GetPreferredSize(); 325 size = notification_view()->GetPreferredSize();
329 size.Enlarge(0, -notification_view()->GetInsets().height()); 326 size.Enlarge(0, -notification_view()->GetInsets().height());
330 EXPECT_EQ("360x1000", size.ToString()); 327 EXPECT_EQ("360x1000", size.ToString());
331 } 328 }
332 329
333 } // namespace message_center 330 } // namespace message_center
OLDNEW
« no previous file with comments | « components/constrained_window/constrained_window_views_unittest.cc ('k') | ui/views/controls/button/image_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698