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

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

Issue 2935893004: Add unittest for ArcNotificationContentView (Closed)
Patch Set: . 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
« no previous file with comments | « ui/arc/DEPS ('k') | ui/arc/notification/arc_notification_content_view.cc » ('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 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
77 void CreateCloseButton(); 82 void CreateCloseButton();
78 void CreateSettingsButton(); 83 void CreateSettingsButton();
79 void MaybeCreateFloatingControlButtons(); 84 void MaybeCreateFloatingControlButtons();
80 void SetSurface(exo::NotificationSurface* surface); 85 void SetSurface(ArcNotificationSurface* surface);
81 void UpdatePreferredSize(); 86 void UpdatePreferredSize();
82 void UpdateControlButtonsVisibility(); 87 void UpdateControlButtonsVisibility();
83 void UpdatePinnedState(); 88 void UpdatePinnedState();
84 void UpdateSnapshot(); 89 void UpdateSnapshot();
85 void AttachSurface(); 90 void AttachSurface();
86 void ActivateToast(); 91 void ActivateToast();
87 void StartControlButtonsColorAnimation(); 92 void StartControlButtonsColorAnimation();
88 bool ShouldUpdateControlButtonsColor() const; 93 bool ShouldUpdateControlButtonsColor() const;
89 void UpdateAccessibleName(); 94 void UpdateAccessibleName();
90 95
(...skipping 17 matching lines...) Expand all
108 void OnWindowBoundsChanged(aura::Window* window, 113 void OnWindowBoundsChanged(aura::Window* window,
109 const gfx::Rect& old_bounds, 114 const gfx::Rect& old_bounds,
110 const gfx::Rect& new_bounds) override; 115 const gfx::Rect& new_bounds) override;
111 void OnWindowDestroying(aura::Window* window) override; 116 void OnWindowDestroying(aura::Window* window) override;
112 117
113 // ArcNotificationItem::Observer 118 // ArcNotificationItem::Observer
114 void OnItemDestroying() override; 119 void OnItemDestroying() override;
115 void OnItemUpdated() override; 120 void OnItemUpdated() override;
116 121
117 // ArcNotificationSurfaceManager::Observer: 122 // ArcNotificationSurfaceManager::Observer:
118 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override; 123 void OnNotificationSurfaceAdded(ArcNotificationSurface* surface) override;
119 void OnNotificationSurfaceRemoved(exo::NotificationSurface* surface) override; 124 void OnNotificationSurfaceRemoved(ArcNotificationSurface* surface) override;
120 125
121 // AnimationDelegate 126 // AnimationDelegate
122 void AnimationEnded(const gfx::Animation* animation) override; 127 void AnimationEnded(const gfx::Animation* animation) override;
123 void AnimationProgressed(const gfx::Animation* animation) override; 128 void AnimationProgressed(const gfx::Animation* animation) override;
124 129
125 // If |item_| is null, we may be about to be destroyed. In this case, 130 // If |item_| is null, we may be about to be destroyed. In this case,
126 // we have to be careful about what we do. 131 // we have to be careful about what we do.
127 ArcNotificationItem* item_ = nullptr; 132 ArcNotificationItem* item_ = nullptr;
128 exo::NotificationSurface* surface_ = nullptr; 133 ArcNotificationSurface* surface_ = nullptr;
129 134
130 const std::string notification_key_; 135 const std::string notification_key_;
131 136
132 // A pre-target event handler to forward events on the surface to this view. 137 // 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 138 // 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 139 // window because it has descendant aura::Window and the events on them need
135 // to be handled as well. 140 // to be handled as well.
136 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window. 141 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window.
137 std::unique_ptr<EventForwarder> event_forwarder_; 142 std::unique_ptr<EventForwarder> event_forwarder_;
138 143
(...skipping 17 matching lines...) Expand all
156 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_; 161 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_;
157 162
158 base::string16 accessible_name_; 163 base::string16 accessible_name_;
159 164
160 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView); 165 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView);
161 }; 166 };
162 167
163 } // namespace arc 168 } // namespace arc
164 169
165 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ 170 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_
OLDNEW
« no previous file with comments | « ui/arc/DEPS ('k') | ui/arc/notification/arc_notification_content_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698