| 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/message_center_tray.h" | 5 #include "ui/message_center/message_center_tray.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/models/menu_model.h" | 9 #include "ui/base/models/menu_model.h" |
| 10 #include "ui/message_center/message_center.h" | 10 #include "ui/message_center/message_center.h" |
| 11 #include "ui/message_center/notification.h" | 11 #include "ui/message_center/notification.h" |
| 12 #include "ui/message_center/notification_types.h" | 12 #include "ui/message_center/notification_types.h" |
| 13 | 13 |
| 14 using base::ASCIIToUTF16; | 14 using base::ASCIIToUTF16; |
| 15 | 15 |
| 16 namespace message_center { | 16 namespace message_center { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class MockDelegate : public MessageCenterTrayDelegate { | 19 class MockDelegate : public MessageCenterTrayDelegate { |
| 20 public: | 20 public: |
| 21 MockDelegate() | 21 MockDelegate() |
| 22 : show_popups_success_(true), | 22 : show_popups_success_(true), |
| 23 show_message_center_success_(true), | 23 show_message_center_success_(true), |
| 24 enable_context_menu_(true) {} | 24 enable_context_menu_(true) {} |
| 25 virtual ~MockDelegate() {} | 25 ~MockDelegate() override {} |
| 26 virtual void OnMessageCenterTrayChanged() override {} | 26 void OnMessageCenterTrayChanged() override {} |
| 27 virtual bool ShowPopups() override { | 27 bool ShowPopups() override { return show_message_center_success_; } |
| 28 return show_message_center_success_; | 28 void HidePopups() override {} |
| 29 } | 29 bool ShowMessageCenter() override { return show_popups_success_; } |
| 30 virtual void HidePopups() override {} | 30 void HideMessageCenter() override {} |
| 31 virtual bool ShowMessageCenter() override { | 31 bool ShowNotifierSettings() override { return true; } |
| 32 return show_popups_success_; | 32 bool IsContextMenuEnabled() const override { return enable_context_menu_; } |
| 33 } | |
| 34 virtual void HideMessageCenter() override {} | |
| 35 virtual bool ShowNotifierSettings() override { | |
| 36 return true; | |
| 37 } | |
| 38 virtual bool IsContextMenuEnabled() const override { | |
| 39 return enable_context_menu_; | |
| 40 } | |
| 41 | 33 |
| 42 virtual MessageCenterTray* GetMessageCenterTray() override { | 34 MessageCenterTray* GetMessageCenterTray() override { return NULL; } |
| 43 return NULL; | |
| 44 } | |
| 45 | 35 |
| 46 bool show_popups_success_; | 36 bool show_popups_success_; |
| 47 bool show_message_center_success_; | 37 bool show_message_center_success_; |
| 48 bool enable_context_menu_; | 38 bool enable_context_menu_; |
| 49 | 39 |
| 50 private: | 40 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(MockDelegate); | 41 DISALLOW_COPY_AND_ASSIGN(MockDelegate); |
| 52 }; | 42 }; |
| 53 | 43 |
| 54 } // namespace | 44 } // namespace |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 model = message_center_tray_->CreateNotificationMenuModel( | 293 model = message_center_tray_->CreateNotificationMenuModel( |
| 304 notifier_id2, base::string16()); | 294 notifier_id2, base::string16()); |
| 305 EXPECT_EQ(1, model->GetItemCount()); | 295 EXPECT_EQ(1, model->GetItemCount()); |
| 306 EXPECT_EQ(second_command, model->GetCommandIdAt(0)); | 296 EXPECT_EQ(second_command, model->GetCommandIdAt(0)); |
| 307 | 297 |
| 308 // The command itself is disabled because delegate disables context menu. | 298 // The command itself is disabled because delegate disables context menu. |
| 309 EXPECT_FALSE(model->IsEnabledAt(0)); | 299 EXPECT_FALSE(model->IsEnabledAt(0)); |
| 310 } | 300 } |
| 311 | 301 |
| 312 } // namespace message_center | 302 } // namespace message_center |
| OLD | NEW |