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

Side by Side Diff: ui/arc/notification/arc_notification_view_unittest.cc

Issue 2870283002: Move message_center::CustomNotificationView to arc::ArcNotificationView (Closed)
Patch Set: Addressed comment 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
« no previous file with comments | « ui/arc/notification/arc_notification_view.cc ('k') | ui/arc/test/run_all_unittests.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 #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"
11 #include "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/arc/notification/arc_notification_content_view_delegate.h"
13 #include "ui/arc/notification/arc_notification_view.h"
12 #include "ui/base/ime/dummy_text_input_client.h" 14 #include "ui/base/ime/dummy_text_input_client.h"
13 #include "ui/base/ime/input_method.h" 15 #include "ui/base/ime/input_method.h"
14 #include "ui/base/ime/text_input_client.h" 16 #include "ui/base/ime/text_input_client.h"
15 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 17 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
16 #include "ui/events/event.h" 18 #include "ui/events/event.h"
17 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
18 #include "ui/events/test/event_generator.h" 20 #include "ui/events/test/event_generator.h"
19 #include "ui/message_center/notification.h" 21 #include "ui/message_center/notification.h"
20 #include "ui/message_center/notification_delegate.h" 22 #include "ui/message_center/notification_delegate.h"
21 #include "ui/message_center/views/custom_notification_view.h"
22 #include "ui/message_center/views/message_center_controller.h" 23 #include "ui/message_center/views/message_center_controller.h"
23 #include "ui/message_center/views/message_view_factory.h" 24 #include "ui/message_center/views/message_view_factory.h"
24 #include "ui/views/background.h" 25 #include "ui/views/background.h"
25 #include "ui/views/controls/button/image_button.h" 26 #include "ui/views/controls/button/image_button.h"
26 #include "ui/views/test/views_test_base.h" 27 #include "ui/views/test/views_test_base.h"
27 28
28 namespace message_center { 29 namespace arc {
29 30
30 namespace { 31 namespace {
31 32
32 const SkColor kBackgroundColor = SK_ColorGREEN; 33 const SkColor kBackgroundColor = SK_ColorGREEN;
33 34
34 class TestCustomView : public views::View { 35 class TestNotificationContentsView : public views::View {
35 public: 36 public:
36 TestCustomView() { 37 TestNotificationContentsView() {
37 SetFocusBehavior(FocusBehavior::ALWAYS); 38 SetFocusBehavior(FocusBehavior::ALWAYS);
38 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); 39 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
39 set_preferred_size(gfx::Size(100, 100)); 40 set_preferred_size(gfx::Size(100, 100));
40 } 41 }
41 ~TestCustomView() override {} 42 ~TestNotificationContentsView() override = default;
42 43
43 void Reset() { 44 void Reset() {
44 mouse_event_count_ = 0; 45 mouse_event_count_ = 0;
45 keyboard_event_count_ = 0; 46 keyboard_event_count_ = 0;
46 } 47 }
47 48
48 // views::View 49 // views::View
49 bool OnMousePressed(const ui::MouseEvent& event) override { 50 bool OnMousePressed(const ui::MouseEvent& event) override {
50 ++mouse_event_count_; 51 ++mouse_event_count_;
51 return true; 52 return true;
52 } 53 }
53 void OnMouseMoved(const ui::MouseEvent& event) override { 54 void OnMouseMoved(const ui::MouseEvent& event) override {
54 ++mouse_event_count_; 55 ++mouse_event_count_;
55 } 56 }
56 void OnMouseReleased(const ui::MouseEvent& event) override { 57 void OnMouseReleased(const ui::MouseEvent& event) override {
57 ++mouse_event_count_; 58 ++mouse_event_count_;
58 } 59 }
59 bool OnKeyPressed(const ui::KeyEvent& event) override { 60 bool OnKeyPressed(const ui::KeyEvent& event) override {
60 ++keyboard_event_count_; 61 ++keyboard_event_count_;
61 return false; 62 return false;
62 } 63 }
63 64
64 int mouse_event_count() const { return mouse_event_count_; } 65 int mouse_event_count() const { return mouse_event_count_; }
65 int keyboard_event_count() const { return keyboard_event_count_; } 66 int keyboard_event_count() const { return keyboard_event_count_; }
66 67
67 private: 68 private:
68 int mouse_event_count_ = 0; 69 int mouse_event_count_ = 0;
69 int keyboard_event_count_ = 0; 70 int keyboard_event_count_ = 0;
70 71
71 DISALLOW_COPY_AND_ASSIGN(TestCustomView); 72 DISALLOW_COPY_AND_ASSIGN(TestNotificationContentsView);
72 }; 73 };
73 74
74 class TestContentViewDelegate : public CustomNotificationContentViewDelegate { 75 class TestContentViewDelegate : public ArcNotificationContentViewDelegate {
75 public: 76 public:
76 bool IsCloseButtonFocused() const override { return false; } 77 bool IsCloseButtonFocused() const override { return false; }
77 void RequestFocusOnCloseButton() override {} 78 void RequestFocusOnCloseButton() override {}
78 void UpdateControlButtonsVisibility() override {} 79 void UpdateControlButtonsVisibility() override {}
79 void OnSlideChanged() override {} 80 void OnSlideChanged() override {}
80 }; 81 };
81 82
82 class TestNotificationDelegate : public NotificationDelegate { 83 class TestNotificationDelegate : public message_center::NotificationDelegate {
83 public: 84 public:
84 TestNotificationDelegate() {} 85 TestNotificationDelegate() = default;
85 86
86 // NotificateDelegate 87 // NotificateDelegate
87 std::unique_ptr<CustomContent> CreateCustomContent() override { 88 std::unique_ptr<message_center::MessageView> CreateCustomMessageView(
88 return base::MakeUnique<CustomContent>( 89 message_center::MessageCenterController* controller,
89 base::MakeUnique<TestCustomView>(), 90 const message_center::Notification& notification) override {
90 base::MakeUnique<TestContentViewDelegate>()); 91 return base::MakeUnique<ArcNotificationView>(
92 base::MakeUnique<TestNotificationContentsView>(),
93 base::MakeUnique<TestContentViewDelegate>(), controller, notification);
91 } 94 }
92 95
93 private: 96 private:
94 ~TestNotificationDelegate() override {} 97 ~TestNotificationDelegate() override = default;
95 98
96 DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate); 99 DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate);
97 }; 100 };
98 101
99 class TestMessageCenterController : public MessageCenterController { 102 class TestMessageCenterController
103 : public message_center::MessageCenterController {
100 public: 104 public:
101 TestMessageCenterController() {} 105 TestMessageCenterController() = default;
102 106
103 // MessageCenterController 107 // MessageCenterController
104 void ClickOnNotification(const std::string& notification_id) override { 108 void ClickOnNotification(const std::string& notification_id) override {
105 // For this test, this method should not be invoked. 109 // For this test, this method should not be invoked.
106 NOTREACHED(); 110 NOTREACHED();
107 } 111 }
108 112
109 void RemoveNotification(const std::string& notification_id, 113 void RemoveNotification(const std::string& notification_id,
110 bool by_user) override { 114 bool by_user) override {
111 removed_ids_.insert(notification_id); 115 removed_ids_.insert(notification_id);
112 } 116 }
113 117
114 std::unique_ptr<ui::MenuModel> CreateMenuModel( 118 std::unique_ptr<ui::MenuModel> CreateMenuModel(
115 const NotifierId& notifier_id, 119 const message_center::NotifierId& notifier_id,
116 const base::string16& display_source) override { 120 const base::string16& display_source) override {
117 // For this test, this method should not be invoked. 121 // For this test, this method should not be invoked.
118 NOTREACHED(); 122 NOTREACHED();
119 return nullptr; 123 return nullptr;
120 } 124 }
121 125
122 bool HasClickedListener(const std::string& notification_id) override { 126 bool HasClickedListener(const std::string& notification_id) override {
123 return false; 127 return false;
124 } 128 }
125 129
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void set_text_input_type(ui::TextInputType type) { type_ = type; } 162 void set_text_input_type(ui::TextInputType type) { type_ = type; }
159 163
160 private: 164 private:
161 ui::TextInputType type_ = ui::TEXT_INPUT_TYPE_NONE; 165 ui::TextInputType type_ = ui::TEXT_INPUT_TYPE_NONE;
162 166
163 DISALLOW_COPY_AND_ASSIGN(TestTextInputClient); 167 DISALLOW_COPY_AND_ASSIGN(TestTextInputClient);
164 }; 168 };
165 169
166 } // namespace 170 } // namespace
167 171
168 class CustomNotificationViewTest : public views::ViewsTestBase { 172 class ArcNotificationViewTest : public views::ViewsTestBase {
169 public: 173 public:
170 CustomNotificationViewTest() {} 174 ArcNotificationViewTest() = default;
171 ~CustomNotificationViewTest() override {} 175 ~ArcNotificationViewTest() override = default;
172 176
173 // views::ViewsTestBase 177 // views::ViewsTestBase
174 void SetUp() override { 178 void SetUp() override {
175 views::ViewsTestBase::SetUp(); 179 views::ViewsTestBase::SetUp();
176 180
177 notification_delegate_ = new TestNotificationDelegate; 181 notification_delegate_ = new TestNotificationDelegate;
178 182
179 notification_.reset(new Notification( 183 notification_ = base::MakeUnique<message_center::Notification>(
180 NOTIFICATION_TYPE_CUSTOM, std::string("notification id"), 184 message_center::NOTIFICATION_TYPE_CUSTOM,
181 base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message"), gfx::Image(), 185 std::string("notification id"), base::UTF8ToUTF16("title"),
186 base::UTF8ToUTF16("message"), gfx::Image(),
182 base::UTF8ToUTF16("display source"), GURL(), 187 base::UTF8ToUTF16("display source"), GURL(),
183 NotifierId(NotifierId::APPLICATION, "extension_id"), 188 message_center::NotifierId(message_center::NotifierId::APPLICATION,
184 message_center::RichNotificationData(), notification_delegate_.get())); 189 "extension_id"),
190 message_center::RichNotificationData(), notification_delegate_.get());
185 191
186 notification_view_.reset(static_cast<CustomNotificationView*>( 192 notification_view_.reset(static_cast<ArcNotificationView*>(
187 MessageViewFactory::Create(controller(), *notification_, true))); 193 message_center::MessageViewFactory::Create(controller(), *notification_,
194 true)));
188 notification_view_->set_owned_by_client(); 195 notification_view_->set_owned_by_client();
189 196
190 views::Widget::InitParams init_params( 197 views::Widget::InitParams init_params(
191 CreateParams(views::Widget::InitParams::TYPE_POPUP)); 198 CreateParams(views::Widget::InitParams::TYPE_POPUP));
192 views::Widget* widget = new views::Widget(); 199 views::Widget* widget = new views::Widget();
193 widget->Init(init_params); 200 widget->Init(init_params);
194 widget->SetContentsView(notification_view_.get()); 201 widget->SetContentsView(notification_view_.get());
195 widget->SetSize(notification_view_->GetPreferredSize()); 202 widget->SetSize(notification_view_->GetPreferredSize());
196 widget->Show(); 203 widget->Show();
197 } 204 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void EndScroll() { 261 void EndScroll() {
255 DispatchGesture(ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 262 DispatchGesture(ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END));
256 } 263 }
257 264
258 void ScrollBy(int dx) { 265 void ScrollBy(int dx) {
259 DispatchGesture( 266 DispatchGesture(
260 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, dx, 0)); 267 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, dx, 0));
261 } 268 }
262 269
263 TestMessageCenterController* controller() { return &controller_; } 270 TestMessageCenterController* controller() { return &controller_; }
264 Notification* notification() { return notification_.get(); } 271 message_center::Notification* notification() { return notification_.get(); }
265 TestCustomView* custom_view() { 272 TestNotificationContentsView* contents_view() {
266 return static_cast<TestCustomView*>(notification_view_->contents_view_); 273 return static_cast<TestNotificationContentsView*>(
274 notification_view_->contents_view_);
267 } 275 }
268 views::Widget* widget() { return notification_view_->GetWidget(); } 276 views::Widget* widget() { return notification_view_->GetWidget(); }
269 CustomNotificationView* notification_view() { 277 ArcNotificationView* notification_view() { return notification_view_.get(); }
270 return notification_view_.get();
271 }
272 278
273 private: 279 private:
274 TestMessageCenterController controller_; 280 TestMessageCenterController controller_;
275 scoped_refptr<TestNotificationDelegate> notification_delegate_; 281 scoped_refptr<TestNotificationDelegate> notification_delegate_;
276 std::unique_ptr<Notification> notification_; 282 std::unique_ptr<message_center::Notification> notification_;
277 std::unique_ptr<CustomNotificationView> notification_view_; 283 std::unique_ptr<ArcNotificationView> notification_view_;
278 284
279 DISALLOW_COPY_AND_ASSIGN(CustomNotificationViewTest); 285 DISALLOW_COPY_AND_ASSIGN(ArcNotificationViewTest);
280 }; 286 };
281 287
282 TEST_F(CustomNotificationViewTest, Background) { 288 TEST_F(ArcNotificationViewTest, Background) {
283 EXPECT_EQ(kBackgroundColor, GetBackgroundColor()); 289 EXPECT_EQ(kBackgroundColor, GetBackgroundColor());
284 } 290 }
285 291
286 TEST_F(CustomNotificationViewTest, Events) { 292 TEST_F(ArcNotificationViewTest, Events) {
287 widget()->Show(); 293 widget()->Show();
288 custom_view()->RequestFocus(); 294 contents_view()->RequestFocus();
289 295
290 EXPECT_EQ(0, custom_view()->mouse_event_count()); 296 EXPECT_EQ(0, contents_view()->mouse_event_count());
291 gfx::Point cursor_location(1, 1); 297 gfx::Point cursor_location(1, 1);
292 views::View::ConvertPointToWidget(custom_view(), &cursor_location); 298 views::View::ConvertPointToWidget(contents_view(), &cursor_location);
293 PerformClick(cursor_location); 299 PerformClick(cursor_location);
294 EXPECT_EQ(2, custom_view()->mouse_event_count()); 300 EXPECT_EQ(2, contents_view()->mouse_event_count());
295 301
296 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location, 302 ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
297 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 303 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
298 widget()->OnMouseEvent(&move); 304 widget()->OnMouseEvent(&move);
299 EXPECT_EQ(3, custom_view()->mouse_event_count()); 305 EXPECT_EQ(3, contents_view()->mouse_event_count());
300 306
301 EXPECT_EQ(0, custom_view()->keyboard_event_count()); 307 EXPECT_EQ(0, contents_view()->keyboard_event_count());
302 KeyPress(ui::VKEY_A); 308 KeyPress(ui::VKEY_A);
303 EXPECT_EQ(1, custom_view()->keyboard_event_count()); 309 EXPECT_EQ(1, contents_view()->keyboard_event_count());
304 } 310 }
305 311
306 TEST_F(CustomNotificationViewTest, SlideOut) { 312 TEST_F(ArcNotificationViewTest, SlideOut) {
307 ui::ScopedAnimationDurationScaleMode zero_duration_scope( 313 ui::ScopedAnimationDurationScaleMode zero_duration_scope(
308 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); 314 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
309 315
310 UpdateNotificationViews(); 316 UpdateNotificationViews();
311 std::string notification_id = notification()->id(); 317 std::string notification_id = notification()->id();
312 318
313 BeginScroll(); 319 BeginScroll();
314 ScrollBy(-10); 320 ScrollBy(-10);
315 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 321 EXPECT_FALSE(controller()->IsRemoved(notification_id));
316 EXPECT_EQ(-10.f, GetNotificationSlideAmount()); 322 EXPECT_EQ(-10.f, GetNotificationSlideAmount());
317 EndScroll(); 323 EndScroll();
318 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 324 EXPECT_FALSE(controller()->IsRemoved(notification_id));
319 EXPECT_EQ(0.f, GetNotificationSlideAmount()); 325 EXPECT_EQ(0.f, GetNotificationSlideAmount());
320 326
321 BeginScroll(); 327 BeginScroll();
322 ScrollBy(-200); 328 ScrollBy(-200);
323 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 329 EXPECT_FALSE(controller()->IsRemoved(notification_id));
324 EXPECT_EQ(-200.f, GetNotificationSlideAmount()); 330 EXPECT_EQ(-200.f, GetNotificationSlideAmount());
325 EndScroll(); 331 EndScroll();
326 EXPECT_TRUE(controller()->IsRemoved(notification_id)); 332 EXPECT_TRUE(controller()->IsRemoved(notification_id));
327 } 333 }
328 334
329 TEST_F(CustomNotificationViewTest, SlideOutNested) { 335 TEST_F(ArcNotificationViewTest, SlideOutNested) {
330 ui::ScopedAnimationDurationScaleMode zero_duration_scope( 336 ui::ScopedAnimationDurationScaleMode zero_duration_scope(
331 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); 337 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
332 338
333 UpdateNotificationViews(); 339 UpdateNotificationViews();
334 notification_view()->SetIsNested(); 340 notification_view()->SetIsNested();
335 std::string notification_id = notification()->id(); 341 std::string notification_id = notification()->id();
336 342
337 BeginScroll(); 343 BeginScroll();
338 ScrollBy(-10); 344 ScrollBy(-10);
339 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 345 EXPECT_FALSE(controller()->IsRemoved(notification_id));
340 EXPECT_EQ(-10.f, GetNotificationSlideAmount()); 346 EXPECT_EQ(-10.f, GetNotificationSlideAmount());
341 EndScroll(); 347 EndScroll();
342 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 348 EXPECT_FALSE(controller()->IsRemoved(notification_id));
343 EXPECT_EQ(0.f, GetNotificationSlideAmount()); 349 EXPECT_EQ(0.f, GetNotificationSlideAmount());
344 350
345 BeginScroll(); 351 BeginScroll();
346 ScrollBy(-200); 352 ScrollBy(-200);
347 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 353 EXPECT_FALSE(controller()->IsRemoved(notification_id));
348 EXPECT_EQ(-200.f, GetNotificationSlideAmount()); 354 EXPECT_EQ(-200.f, GetNotificationSlideAmount());
349 EndScroll(); 355 EndScroll();
350 EXPECT_TRUE(controller()->IsRemoved(notification_id)); 356 EXPECT_TRUE(controller()->IsRemoved(notification_id));
351 } 357 }
352 358
353 // Pinning notification is ChromeOS only feature. 359 // Pinning notification is ChromeOS only feature.
354 #if defined(OS_CHROMEOS) 360 #if defined(OS_CHROMEOS)
355 361
356 TEST_F(CustomNotificationViewTest, SlideOutPinned) { 362 TEST_F(ArcNotificationViewTest, SlideOutPinned) {
357 ui::ScopedAnimationDurationScaleMode zero_duration_scope( 363 ui::ScopedAnimationDurationScaleMode zero_duration_scope(
358 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); 364 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
359 365
360 notification()->set_pinned(true); 366 notification()->set_pinned(true);
361 UpdateNotificationViews(); 367 UpdateNotificationViews();
362 std::string notification_id = notification()->id(); 368 std::string notification_id = notification()->id();
363 369
364 BeginScroll(); 370 BeginScroll();
365 ScrollBy(-200); 371 ScrollBy(-200);
366 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 372 EXPECT_FALSE(controller()->IsRemoved(notification_id));
367 EXPECT_LT(-200.f, GetNotificationSlideAmount()); 373 EXPECT_LT(-200.f, GetNotificationSlideAmount());
368 EndScroll(); 374 EndScroll();
369 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 375 EXPECT_FALSE(controller()->IsRemoved(notification_id));
370 } 376 }
371 377
372 #endif // defined(OS_CHROMEOS) 378 #endif // defined(OS_CHROMEOS)
373 379
374 TEST_F(CustomNotificationViewTest, PressBackspaceKey) { 380 TEST_F(ArcNotificationViewTest, PressBackspaceKey) {
375 std::string notification_id = notification()->id(); 381 std::string notification_id = notification()->id();
376 custom_view()->RequestFocus(); 382 contents_view()->RequestFocus();
377 383
378 ui::InputMethod* input_method = custom_view()->GetInputMethod(); 384 ui::InputMethod* input_method = contents_view()->GetInputMethod();
379 ASSERT_TRUE(input_method); 385 ASSERT_TRUE(input_method);
380 TestTextInputClient text_input_client; 386 TestTextInputClient text_input_client;
381 input_method->SetFocusedTextInputClient(&text_input_client); 387 input_method->SetFocusedTextInputClient(&text_input_client);
382 ASSERT_EQ(&text_input_client, input_method->GetTextInputClient()); 388 ASSERT_EQ(&text_input_client, input_method->GetTextInputClient());
383 389
384 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 390 EXPECT_FALSE(controller()->IsRemoved(notification_id));
385 PerformKeyEvents(ui::VKEY_BACK); 391 PerformKeyEvents(ui::VKEY_BACK);
386 EXPECT_TRUE(controller()->IsRemoved(notification_id)); 392 EXPECT_TRUE(controller()->IsRemoved(notification_id));
387 393
388 input_method->SetFocusedTextInputClient(nullptr); 394 input_method->SetFocusedTextInputClient(nullptr);
389 } 395 }
390 396
391 TEST_F(CustomNotificationViewTest, PressBackspaceKeyOnEditBox) { 397 TEST_F(ArcNotificationViewTest, PressBackspaceKeyOnEditBox) {
392 std::string notification_id = notification()->id(); 398 std::string notification_id = notification()->id();
393 custom_view()->RequestFocus(); 399 contents_view()->RequestFocus();
394 400
395 ui::InputMethod* input_method = custom_view()->GetInputMethod(); 401 ui::InputMethod* input_method = contents_view()->GetInputMethod();
396 ASSERT_TRUE(input_method); 402 ASSERT_TRUE(input_method);
397 TestTextInputClient text_input_client; 403 TestTextInputClient text_input_client;
398 input_method->SetFocusedTextInputClient(&text_input_client); 404 input_method->SetFocusedTextInputClient(&text_input_client);
399 ASSERT_EQ(&text_input_client, input_method->GetTextInputClient()); 405 ASSERT_EQ(&text_input_client, input_method->GetTextInputClient());
400 406
401 text_input_client.set_text_input_type(ui::TEXT_INPUT_TYPE_TEXT); 407 text_input_client.set_text_input_type(ui::TEXT_INPUT_TYPE_TEXT);
402 408
403 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 409 EXPECT_FALSE(controller()->IsRemoved(notification_id));
404 PerformKeyEvents(ui::VKEY_BACK); 410 PerformKeyEvents(ui::VKEY_BACK);
405 EXPECT_FALSE(controller()->IsRemoved(notification_id)); 411 EXPECT_FALSE(controller()->IsRemoved(notification_id));
406 412
407 input_method->SetFocusedTextInputClient(nullptr); 413 input_method->SetFocusedTextInputClient(nullptr);
408 } 414 }
409 415
410 TEST_F(CustomNotificationViewTest, ChangeContentHeight) { 416 TEST_F(ArcNotificationViewTest, ChangeContentHeight) {
411 // Default size. 417 // Default size.
412 gfx::Size size = notification_view()->GetPreferredSize(); 418 gfx::Size size = notification_view()->GetPreferredSize();
413 size.Enlarge(0, -notification_view()->GetInsets().height()); 419 size.Enlarge(0, -notification_view()->GetInsets().height());
414 EXPECT_EQ("360x100", size.ToString()); 420 EXPECT_EQ("360x100", size.ToString());
415 421
416 // Allow small notifications. 422 // Allow small notifications.
417 custom_view()->set_preferred_size(gfx::Size(10, 10)); 423 contents_view()->set_preferred_size(gfx::Size(10, 10));
418 size = notification_view()->GetPreferredSize(); 424 size = notification_view()->GetPreferredSize();
419 size.Enlarge(0, -notification_view()->GetInsets().height()); 425 size.Enlarge(0, -notification_view()->GetInsets().height());
420 EXPECT_EQ("360x10", size.ToString()); 426 EXPECT_EQ("360x10", size.ToString());
421 427
422 // The long notification. 428 // The long notification.
423 custom_view()->set_preferred_size(gfx::Size(1000, 1000)); 429 contents_view()->set_preferred_size(gfx::Size(1000, 1000));
424 size = notification_view()->GetPreferredSize(); 430 size = notification_view()->GetPreferredSize();
425 size.Enlarge(0, -notification_view()->GetInsets().height()); 431 size.Enlarge(0, -notification_view()->GetInsets().height());
426 EXPECT_EQ("360x1000", size.ToString()); 432 EXPECT_EQ("360x1000", size.ToString());
427 } 433 }
428 434
429 } // namespace message_center 435 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_view.cc ('k') | ui/arc/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698