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

Side by Side Diff: ui/arc/notification/arc_notification_content_view.h

Issue 2935893004: Add unittest for ArcNotificationContentView (Closed)
Patch Set: Rebased Created 3 years, 6 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 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_
6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/arc/notification/arc_notification_content_view_delegate.h" 12 #include "ui/arc/notification/arc_notification_content_view_delegate.h"
13 #include "ui/arc/notification/arc_notification_item.h" 13 #include "ui/arc/notification/arc_notification_item.h"
14 #include "ui/arc/notification/arc_notification_surface_manager.h" 14 #include "ui/arc/notification/arc_notification_surface_manager.h"
15 #include "ui/aura/window_observer.h" 15 #include "ui/aura/window_observer.h"
16 #include "ui/gfx/animation/animation_delegate.h" 16 #include "ui/gfx/animation/animation_delegate.h"
17 #include "ui/message_center/views/padded_button.h" 17 #include "ui/message_center/views/padded_button.h"
18 #include "ui/views/controls/button/button.h" 18 #include "ui/views/controls/button/button.h"
19 #include "ui/views/controls/native/native_view_host.h" 19 #include "ui/views/controls/native/native_view_host.h"
20 20
21 namespace exo {
22 class NotificationSurface;
23 }
24
25 namespace gfx { 21 namespace gfx {
26 class LinearAnimation; 22 class LinearAnimation;
27 } 23 }
28 24
29 namespace ui { 25 namespace ui {
30 struct AXActionData; 26 struct AXActionData;
31 } 27 }
32 28
33 namespace views { 29 namespace views {
34 class FocusTraversable; 30 class FocusTraversable;
35 class Widget; 31 class Widget;
36 } 32 }
37 33
38 namespace arc { 34 namespace arc {
39 35
36 class ArcNotificationSurface;
37
40 // ArcNotificationContentView is a view to host NotificationSurface and show the 38 // ArcNotificationContentView is a view to host NotificationSurface and show the
41 // content in itself. This is implemented as a child of ArcNotificationView. 39 // content in itself. This is implemented as a child of ArcNotificationView.
42 class ArcNotificationContentView 40 class ArcNotificationContentView
43 : public views::NativeViewHost, 41 : public views::NativeViewHost,
44 public views::ButtonListener, 42 public views::ButtonListener,
45 public aura::WindowObserver, 43 public aura::WindowObserver,
46 public ArcNotificationItem::Observer, 44 public ArcNotificationItem::Observer,
47 public ArcNotificationSurfaceManager::Observer, 45 public ArcNotificationSurfaceManager::Observer,
48 public gfx::AnimationDelegate { 46 public gfx::AnimationDelegate {
49 public: 47 public:
48 static const char kViewClassName[];
49
50 explicit ArcNotificationContentView(ArcNotificationItem* item); 50 explicit ArcNotificationContentView(ArcNotificationItem* item);
51 ~ArcNotificationContentView() override; 51 ~ArcNotificationContentView() override;
52 52
53 // views::View overrides:
54 const char* GetClassName() const override;
55
53 std::unique_ptr<ArcNotificationContentViewDelegate> 56 std::unique_ptr<ArcNotificationContentViewDelegate>
54 CreateContentViewDelegate(); 57 CreateContentViewDelegate();
55 58
56 private: 59 private:
60 friend class ArcNotificationContentViewTest;
61
57 class ContentViewDelegate; 62 class ContentViewDelegate;
58 class EventForwarder; 63 class EventForwarder;
59 class SettingsButton; 64 class SettingsButton;
60 class SlideHelper; 65 class SlideHelper;
61 66
62 // A image button class used for the settings button and the close button. 67 // A image button class used for the settings button and the close button.
63 // We can't use forward declaration for this class due to std::unique_ptr<> 68 // We can't use forward declaration for this class due to std::unique_ptr<>
64 // requires size of this class. 69 // requires size of this class.
65 class ControlButton : public message_center::PaddedButton { 70 class ControlButton : public message_center::PaddedButton {
66 public: 71 public:
67 explicit ControlButton(ArcNotificationContentView* owner); 72 explicit ControlButton(ArcNotificationContentView* owner);
68 void OnFocus() override; 73 void OnFocus() override;
69 void OnBlur() override; 74 void OnBlur() override;
70 75
71 private: 76 private:
72 ArcNotificationContentView* const owner_; 77 ArcNotificationContentView* const owner_;
73 78
74 DISALLOW_COPY_AND_ASSIGN(ControlButton); 79 DISALLOW_COPY_AND_ASSIGN(ControlButton);
75 }; 80 };
76 81
82 ArcNotificationSurfaceManager* GetSurfaceManager() const;
hidehiko 2017/06/15 15:26:20 nit: please move this into anonymous namespace in
yoshiki 2017/06/16 11:29:08 I completely removed this method.
77 void CreateCloseButton(); 83 void CreateCloseButton();
78 void CreateSettingsButton(); 84 void CreateSettingsButton();
79 void MaybeCreateFloatingControlButtons(); 85 void MaybeCreateFloatingControlButtons();
80 void SetSurface(exo::NotificationSurface* surface); 86 void SetSurface(ArcNotificationSurface* surface);
81 void UpdatePreferredSize(); 87 void UpdatePreferredSize();
82 void UpdateControlButtonsVisibility(); 88 void UpdateControlButtonsVisibility();
83 void UpdatePinnedState(); 89 void UpdatePinnedState();
84 void UpdateSnapshot(); 90 void UpdateSnapshot();
85 void AttachSurface(); 91 void AttachSurface();
86 void ActivateToast(); 92 void ActivateToast();
87 void StartControlButtonsColorAnimation(); 93 void StartControlButtonsColorAnimation();
88 bool ShouldUpdateControlButtonsColor() const; 94 bool ShouldUpdateControlButtonsColor() const;
89 void UpdateAccessibleName(); 95 void UpdateAccessibleName();
90 96
(...skipping 17 matching lines...) Expand all
108 void OnWindowBoundsChanged(aura::Window* window, 114 void OnWindowBoundsChanged(aura::Window* window,
109 const gfx::Rect& old_bounds, 115 const gfx::Rect& old_bounds,
110 const gfx::Rect& new_bounds) override; 116 const gfx::Rect& new_bounds) override;
111 void OnWindowDestroying(aura::Window* window) override; 117 void OnWindowDestroying(aura::Window* window) override;
112 118
113 // ArcNotificationItem::Observer 119 // ArcNotificationItem::Observer
114 void OnItemDestroying() override; 120 void OnItemDestroying() override;
115 void OnItemUpdated() override; 121 void OnItemUpdated() override;
116 122
117 // ArcNotificationSurfaceManager::Observer: 123 // ArcNotificationSurfaceManager::Observer:
118 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override; 124 void OnNotificationSurfaceAdded(ArcNotificationSurface* surface) override;
119 void OnNotificationSurfaceRemoved(exo::NotificationSurface* surface) override; 125 void OnNotificationSurfaceRemoved(ArcNotificationSurface* surface) override;
120 126
121 // AnimationDelegate 127 // AnimationDelegate
122 void AnimationEnded(const gfx::Animation* animation) override; 128 void AnimationEnded(const gfx::Animation* animation) override;
123 void AnimationProgressed(const gfx::Animation* animation) override; 129 void AnimationProgressed(const gfx::Animation* animation) override;
124 130
125 // If |item_| is null, we may be about to be destroyed. In this case, 131 // If |item_| is null, we may be about to be destroyed. In this case,
126 // we have to be careful about what we do. 132 // we have to be careful about what we do.
127 ArcNotificationItem* item_ = nullptr; 133 ArcNotificationItem* item_ = nullptr;
128 exo::NotificationSurface* surface_ = nullptr; 134 ArcNotificationSurface* surface_ = nullptr;
129 135
130 const std::string notification_key_; 136 const std::string notification_key_;
131 137
132 // A pre-target event handler to forward events on the surface to this view. 138 // A pre-target event handler to forward events on the surface to this view.
133 // Using a pre-target event handler instead of a target handler on the surface 139 // Using a pre-target event handler instead of a target handler on the surface
134 // window because it has descendant aura::Window and the events on them need 140 // window because it has descendant aura::Window and the events on them need
135 // to be handled as well. 141 // to be handled as well.
136 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window. 142 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window.
137 std::unique_ptr<EventForwarder> event_forwarder_; 143 std::unique_ptr<EventForwarder> event_forwarder_;
138 144
(...skipping 17 matching lines...) Expand all
156 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_; 162 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_;
157 163
158 base::string16 accessible_name_; 164 base::string16 accessible_name_;
159 165
160 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView); 166 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView);
161 }; 167 };
162 168
163 } // namespace arc 169 } // namespace arc
164 170
165 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ 171 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698