OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_center/views/message_popup_collection.h" | 5 #include "ui/message_center/views/message_popup_collection.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
14 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 #include "ui/message_center/fake_message_center.h" | 17 #include "ui/message_center/fake_message_center.h" |
18 #include "ui/message_center/views/desktop_popup_alignment_delegate.h" | 18 #include "ui/message_center/views/desktop_popup_alignment_delegate.h" |
19 #include "ui/message_center/views/toast_contents_view.h" | 19 #include "ui/message_center/views/toast_contents_view.h" |
20 #include "ui/views/test/views_test_base.h" | 20 #include "ui/views/test/views_test_base.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 #include "ui/views/widget/widget_delegate.h" | 22 #include "ui/views/widget/widget_delegate.h" |
23 | 23 |
24 namespace message_center { | 24 namespace message_center { |
25 namespace test { | 25 namespace test { |
26 | 26 |
27 class MessagePopupCollectionTest : public views::ViewsTestBase { | 27 class MessagePopupCollectionTest : public views::ViewsTestBase { |
28 public: | 28 public: |
29 virtual void SetUp() override { | 29 void SetUp() override { |
30 views::ViewsTestBase::SetUp(); | 30 views::ViewsTestBase::SetUp(); |
31 MessageCenter::Initialize(); | 31 MessageCenter::Initialize(); |
32 MessageCenter::Get()->DisableTimersForTest(); | 32 MessageCenter::Get()->DisableTimersForTest(); |
33 alignment_delegate_.reset(new DesktopPopupAlignmentDelegate); | 33 alignment_delegate_.reset(new DesktopPopupAlignmentDelegate); |
34 collection_.reset(new MessagePopupCollection( | 34 collection_.reset(new MessagePopupCollection( |
35 GetContext(), MessageCenter::Get(), NULL, alignment_delegate_.get())); | 35 GetContext(), MessageCenter::Get(), NULL, alignment_delegate_.get())); |
36 // This size fits test machines resolution and also can keep a few toasts | 36 // This size fits test machines resolution and also can keep a few toasts |
37 // w/o ill effects of hitting the screen overflow. This allows us to assume | 37 // w/o ill effects of hitting the screen overflow. This allows us to assume |
38 // and verify normal layout of the toast stack. | 38 // and verify normal layout of the toast stack. |
39 SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // taskbar at the bottom. | 39 SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // taskbar at the bottom. |
40 gfx::Rect(0, 0, 600, 400)); | 40 gfx::Rect(0, 0, 600, 400)); |
41 id_ = 0; | 41 id_ = 0; |
42 PrepareForWait(); | 42 PrepareForWait(); |
43 } | 43 } |
44 | 44 |
45 virtual void TearDown() override { | 45 void TearDown() override { |
46 collection_.reset(); | 46 collection_.reset(); |
47 MessageCenter::Shutdown(); | 47 MessageCenter::Shutdown(); |
48 views::ViewsTestBase::TearDown(); | 48 views::ViewsTestBase::TearDown(); |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 MessagePopupCollection* collection() { return collection_.get(); } | 52 MessagePopupCollection* collection() { return collection_.get(); } |
53 | 53 |
54 size_t GetToastCounts() { | 54 size_t GetToastCounts() { |
55 return collection_->toasts_.size(); | 55 return collection_->toasts_.size(); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 std::string id2 = AddNotification(); | 412 std::string id2 = AddNotification(); |
413 | 413 |
414 WaitForTransitionsDone(); | 414 WaitForTransitionsDone(); |
415 views::WidgetDelegateView* toast2 = GetToast(id2); | 415 views::WidgetDelegateView* toast2 = GetToast(id2); |
416 EXPECT_TRUE(toast2 != NULL); | 416 EXPECT_TRUE(toast2 != NULL); |
417 } | 417 } |
418 | 418 |
419 | 419 |
420 } // namespace test | 420 } // namespace test |
421 } // namespace message_center | 421 } // namespace message_center |
OLD | NEW |