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

Unified Diff: ui/arc/notification/arc_notification_view_unittest.cc

Issue 2870283002: Move message_center::CustomNotificationView to arc::ArcNotificationView (Closed)
Patch Set: Fixed test 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 side-by-side diff with in-line comments
Download patch
Index: ui/arc/notification/arc_notification_view_unittest.cc
diff --git a/ui/message_center/views/custom_notification_view_unittest.cc b/ui/arc/notification/arc_notification_view_unittest.cc
similarity index 72%
rename from ui/message_center/views/custom_notification_view_unittest.cc
rename to ui/arc/notification/arc_notification_view_unittest.cc
index 158e010c9dc6edc0567c3b039faa558600423884..18005e062f3fb15bf17ecb5b6b7dde54720079d1 100644
--- a/ui/message_center/views/custom_notification_view_unittest.cc
+++ b/ui/arc/notification/arc_notification_view_unittest.cc
@@ -9,6 +9,8 @@
#include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/arc/notification/arc_notification_content_view_delegate.h"
+#include "ui/arc/notification/arc_notification_view.h"
#include "ui/base/ime/dummy_text_input_client.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
@@ -16,26 +18,25 @@
#include "ui/events/event_utils.h"
#include "ui/message_center/notification.h"
#include "ui/message_center/notification_delegate.h"
-#include "ui/message_center/views/custom_notification_view.h"
#include "ui/message_center/views/message_center_controller.h"
#include "ui/message_center/views/message_view_factory.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/test/views_test_base.h"
-namespace message_center {
+namespace arc {
namespace {
const SkColor kBackgroundColor = SK_ColorGREEN;
-class TestCustomView : public views::View {
+class TestNotificationContentsView : public views::View {
public:
- TestCustomView() {
+ TestNotificationContentsView() {
SetFocusBehavior(FocusBehavior::ALWAYS);
set_background(views::Background::CreateSolidBackground(kBackgroundColor));
}
- ~TestCustomView() override {}
+ ~TestNotificationContentsView() override {}
hidehiko 2017/05/11 14:22:47 Similarly, s/{}/= default;/ Ditto for below.
yoshiki 2017/05/12 08:42:38 Done.
void Reset() {
mouse_event_count_ = 0;
@@ -69,25 +70,27 @@ class TestCustomView : public views::View {
int keyboard_event_count_ = 0;
gfx::Size preferred_size_ = gfx::Size(100, 100);
- DISALLOW_COPY_AND_ASSIGN(TestCustomView);
+ DISALLOW_COPY_AND_ASSIGN(TestNotificationContentsView);
};
-class TestContentViewDelegate : public CustomNotificationContentViewDelegate {
+class TestContentViewDelegate : public ArcNotificationContentViewDelegate {
public:
bool IsCloseButtonFocused() const override { return false; }
void RequestFocusOnCloseButton() override {}
void UpdateControlButtonsVisibility() override {}
};
-class TestNotificationDelegate : public NotificationDelegate {
+class TestNotificationDelegate : public message_center::NotificationDelegate {
public:
TestNotificationDelegate() {}
// NotificateDelegate
- std::unique_ptr<CustomContent> CreateCustomContent() override {
- return base::MakeUnique<CustomContent>(
- base::MakeUnique<TestCustomView>(),
- base::MakeUnique<TestContentViewDelegate>());
+ std::unique_ptr<message_center::MessageView> CreateCustomMessageView(
+ message_center::MessageCenterController* controller,
+ const message_center::Notification& notification) override {
+ return base::MakeUnique<ArcNotificationView>(
+ base::MakeUnique<TestNotificationContentsView>(),
+ base::MakeUnique<TestContentViewDelegate>(), controller, notification);
}
private:
@@ -96,7 +99,8 @@ class TestNotificationDelegate : public NotificationDelegate {
DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate);
};
-class TestMessageCenterController : public MessageCenterController {
+class TestMessageCenterController
+ : public message_center::MessageCenterController {
public:
TestMessageCenterController() {}
@@ -112,7 +116,7 @@ class TestMessageCenterController : public MessageCenterController {
}
std::unique_ptr<ui::MenuModel> CreateMenuModel(
- const NotifierId& notifier_id,
+ const message_center::NotifierId& notifier_id,
const base::string16& display_source) override {
// For this test, this method should not be invoked.
NOTREACHED();
@@ -165,10 +169,10 @@ class TestTextInputClient : public ui::DummyTextInputClient {
} // namespace
-class CustomNotificationViewTest : public views::ViewsTestBase {
+class ArcNotificationViewTest : public views::ViewsTestBase {
public:
- CustomNotificationViewTest() {}
- ~CustomNotificationViewTest() override {}
+ ArcNotificationViewTest() {}
+ ~ArcNotificationViewTest() override {}
// views::ViewsTestBase
void SetUp() override {
@@ -176,15 +180,18 @@ class CustomNotificationViewTest : public views::ViewsTestBase {
notification_delegate_ = new TestNotificationDelegate;
- notification_.reset(new Notification(
- NOTIFICATION_TYPE_CUSTOM, std::string("notification id"),
- base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message"), gfx::Image(),
+ notification_.reset(new message_center::Notification(
hidehiko 2017/05/11 14:22:47 nit/style: Could you use base::MakeUnique<> instea
yoshiki 2017/05/12 08:42:38 Done.
+ message_center::NOTIFICATION_TYPE_CUSTOM,
+ std::string("notification id"), base::UTF8ToUTF16("title"),
+ base::UTF8ToUTF16("message"), gfx::Image(),
base::UTF8ToUTF16("display source"), GURL(),
- NotifierId(NotifierId::APPLICATION, "extension_id"),
+ message_center::NotifierId(message_center::NotifierId::APPLICATION,
+ "extension_id"),
message_center::RichNotificationData(), notification_delegate_.get()));
- notification_view_.reset(static_cast<CustomNotificationView*>(
- MessageViewFactory::Create(controller(), *notification_, true)));
+ notification_view_.reset(static_cast<ArcNotificationView*>(
hidehiko 2017/05/11 14:22:47 Ditto.
yoshiki 2017/05/12 08:42:38 This line doesn't construct an object so we can't
+ message_center::MessageViewFactory::Create(controller(), *notification_,
+ true)));
notification_view_->set_owned_by_client();
views::Widget::InitParams init_params(
@@ -233,53 +240,52 @@ class CustomNotificationViewTest : public views::ViewsTestBase {
}
TestMessageCenterController* controller() { return &controller_; }
- Notification* notification() { return notification_.get(); }
- TestCustomView* custom_view() {
- return static_cast<TestCustomView*>(notification_view_->contents_view_);
+ message_center::Notification* notification() { return notification_.get(); }
+ TestNotificationContentsView* contents_view() {
+ return static_cast<TestNotificationContentsView*>(
+ notification_view_->contents_view_);
}
views::Widget* widget() { return notification_view_->GetWidget(); }
- CustomNotificationView* notification_view() {
- return notification_view_.get();
- }
+ ArcNotificationView* notification_view() { return notification_view_.get(); }
private:
TestMessageCenterController controller_;
scoped_refptr<TestNotificationDelegate> notification_delegate_;
- std::unique_ptr<Notification> notification_;
- std::unique_ptr<CustomNotificationView> notification_view_;
+ std::unique_ptr<message_center::Notification> notification_;
+ std::unique_ptr<ArcNotificationView> notification_view_;
- DISALLOW_COPY_AND_ASSIGN(CustomNotificationViewTest);
+ DISALLOW_COPY_AND_ASSIGN(ArcNotificationViewTest);
};
-TEST_F(CustomNotificationViewTest, Background) {
+TEST_F(ArcNotificationViewTest, Background) {
EXPECT_EQ(kBackgroundColor, GetBackgroundColor());
}
-TEST_F(CustomNotificationViewTest, Events) {
+TEST_F(ArcNotificationViewTest, Events) {
widget()->Show();
- custom_view()->RequestFocus();
+ contents_view()->RequestFocus();
- EXPECT_EQ(0, custom_view()->mouse_event_count());
+ EXPECT_EQ(0, contents_view()->mouse_event_count());
gfx::Point cursor_location(1, 1);
- views::View::ConvertPointToWidget(custom_view(), &cursor_location);
+ views::View::ConvertPointToWidget(contents_view(), &cursor_location);
PerformClick(cursor_location);
- EXPECT_EQ(2, custom_view()->mouse_event_count());
+ EXPECT_EQ(2, contents_view()->mouse_event_count());
ui::MouseEvent move(ui::ET_MOUSE_MOVED, cursor_location, cursor_location,
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
widget()->OnMouseEvent(&move);
- EXPECT_EQ(3, custom_view()->mouse_event_count());
+ EXPECT_EQ(3, contents_view()->mouse_event_count());
- EXPECT_EQ(0, custom_view()->keyboard_event_count());
+ EXPECT_EQ(0, contents_view()->keyboard_event_count());
KeyPress(ui::VKEY_A);
- EXPECT_EQ(1, custom_view()->keyboard_event_count());
+ EXPECT_EQ(1, contents_view()->keyboard_event_count());
}
-TEST_F(CustomNotificationViewTest, PressBackspaceKey) {
+TEST_F(ArcNotificationViewTest, PressBackspaceKey) {
std::string notification_id = notification()->id();
- custom_view()->RequestFocus();
+ contents_view()->RequestFocus();
- ui::InputMethod* input_method = custom_view()->GetInputMethod();
+ ui::InputMethod* input_method = contents_view()->GetInputMethod();
ASSERT_TRUE(input_method);
TestTextInputClient text_input_client;
input_method->SetFocusedTextInputClient(&text_input_client);
@@ -292,11 +298,11 @@ TEST_F(CustomNotificationViewTest, PressBackspaceKey) {
input_method->SetFocusedTextInputClient(nullptr);
}
-TEST_F(CustomNotificationViewTest, PressBackspaceKeyOnEditBox) {
+TEST_F(ArcNotificationViewTest, PressBackspaceKeyOnEditBox) {
std::string notification_id = notification()->id();
- custom_view()->RequestFocus();
+ contents_view()->RequestFocus();
- ui::InputMethod* input_method = custom_view()->GetInputMethod();
+ ui::InputMethod* input_method = contents_view()->GetInputMethod();
ASSERT_TRUE(input_method);
TestTextInputClient text_input_client;
input_method->SetFocusedTextInputClient(&text_input_client);
@@ -311,23 +317,23 @@ TEST_F(CustomNotificationViewTest, PressBackspaceKeyOnEditBox) {
input_method->SetFocusedTextInputClient(nullptr);
}
-TEST_F(CustomNotificationViewTest, ChangeContentHeight) {
+TEST_F(ArcNotificationViewTest, ChangeContentHeight) {
// Default size.
gfx::Size size = notification_view()->GetPreferredSize();
size.Enlarge(0, -notification_view()->GetInsets().height());
EXPECT_EQ("360x100", size.ToString());
// Allow small notifications.
- custom_view()->set_preferred_size(gfx::Size(10, 10));
+ contents_view()->set_preferred_size(gfx::Size(10, 10));
size = notification_view()->GetPreferredSize();
size.Enlarge(0, -notification_view()->GetInsets().height());
EXPECT_EQ("360x10", size.ToString());
// The long notification.
- custom_view()->set_preferred_size(gfx::Size(1000, 1000));
+ contents_view()->set_preferred_size(gfx::Size(1000, 1000));
size = notification_view()->GetPreferredSize();
size.Enlarge(0, -notification_view()->GetInsets().height());
EXPECT_EQ("360x1000", size.ToString());
}
-} // namespace message_center
+} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698