| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/usb/web_usb_detector.h" | 11 #include "chrome/browser/usb/web_usb_detector.h" |
| 11 #include "device/base/mock_device_client.h" | 12 #include "device/base/mock_device_client.h" |
| 12 #include "device/usb/mock_usb_device.h" | 13 #include "device/usb/mock_usb_device.h" |
| 13 #include "device/usb/mock_usb_service.h" | 14 #include "device/usb/mock_usb_service.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/message_center/message_center.h" | 16 #include "ui/message_center/message_center.h" |
| 16 #include "ui/message_center/notification.h" | 17 #include "ui/message_center/notification.h" |
| 17 #include "ui/message_center/notification_delegate.h" | 18 #include "ui/message_center/notification_delegate.h" |
| 18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 19 | 20 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 const char* kLandingPage_3 = "https://www.google.com/C"; | 35 const char* kLandingPage_3 = "https://www.google.com/C"; |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| 37 | 38 |
| 38 class WebUsbDetectorTest : public testing::Test { | 39 class WebUsbDetectorTest : public testing::Test { |
| 39 public: | 40 public: |
| 40 WebUsbDetectorTest() {} | 41 WebUsbDetectorTest() {} |
| 41 ~WebUsbDetectorTest() override = default; | 42 ~WebUsbDetectorTest() override = default; |
| 42 | 43 |
| 43 void SetUp() override { | 44 void SetUp() override { |
| 44 message_center::MessageCenter::Initialize(); | 45 message_center_ = g_browser_process->message_center(); |
| 45 message_center_ = message_center::MessageCenter::Get(); | |
| 46 ASSERT_TRUE(message_center_ != nullptr); | 46 ASSERT_TRUE(message_center_ != nullptr); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TearDown() override { message_center::MessageCenter::Shutdown(); } | 49 void TearDown() override { message_center_ = nullptr; } |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 device::MockDeviceClient device_client_; | 52 device::MockDeviceClient device_client_; |
| 53 message_center::MessageCenter* message_center_; | 53 message_center::MessageCenter* message_center_; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(WebUsbDetectorTest); | 56 DISALLOW_COPY_AND_ASSIGN(WebUsbDetectorTest); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TEST_F(WebUsbDetectorTest, UsbDeviceAddedAndRemoved) { | 59 TEST_F(WebUsbDetectorTest, UsbDeviceAddedAndRemoved) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 EXPECT_EQ(expected_message_3, notification_3->message()); | 397 EXPECT_EQ(expected_message_3, notification_3->message()); |
| 398 EXPECT_TRUE(notification_3->delegate() != nullptr); | 398 EXPECT_TRUE(notification_3->delegate() != nullptr); |
| 399 | 399 |
| 400 device_client_.usb_service()->RemoveDevice(device_1); | 400 device_client_.usb_service()->RemoveDevice(device_1); |
| 401 EXPECT_EQ(nullptr, message_center_->FindVisibleNotificationById(guid_1)); | 401 EXPECT_EQ(nullptr, message_center_->FindVisibleNotificationById(guid_1)); |
| 402 | 402 |
| 403 device_client_.usb_service()->RemoveDevice(device_3); | 403 device_client_.usb_service()->RemoveDevice(device_3); |
| 404 EXPECT_EQ(nullptr, message_center_->FindVisibleNotificationById(guid_3)); | 404 EXPECT_EQ(nullptr, message_center_->FindVisibleNotificationById(guid_3)); |
| 405 } | 405 } |
| 406 #endif // !OS_WIN | 406 #endif // !OS_WIN |
| OLD | NEW |