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

Side by Side Diff: chrome/browser/usb/web_usb_detector_unittest.cc

Issue 2528013002: Initialize the message center as part of the testing browser process (Closed)
Patch Set: re-uploding due to time outs Created 4 years 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
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc ('k') | chrome/test/base/testing_browser_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698