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

Side by Side Diff: chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc

Issue 2504513002: Make FakeChromeUserManager subclass of ChromeUserManager (Closed)
Patch Set: Addressed comment Created 4 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/printer_detector/printer_detector.h" 5 #include "chrome/browser/chromeos/printer_detector/printer_detector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 17 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
17 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h" 18 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 19 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/extensions/test_extension_system.h" 20 #include "chrome/browser/extensions/test_extension_system.h"
20 #include "chrome/browser/notifications/notification.h" 21 #include "chrome/browser/notifications/notification.h"
21 #include "chrome/browser/notifications/notification_test_util.h" 22 #include "chrome/browser/notifications/notification_test_util.h"
22 #include "chrome/browser/notifications/notification_ui_manager.h" 23 #include "chrome/browser/notifications/notification_ui_manager.h"
23 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
24 #include "components/user_manager/fake_user_manager.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "device/base/mock_device_client.h" 26 #include "device/base/mock_device_client.h"
27 #include "device/usb/mock_usb_device.h" 27 #include "device/usb/mock_usb_device.h"
28 #include "device/usb/mock_usb_service.h" 28 #include "device/usb/mock_usb_service.h"
29 #include "device/usb/usb_descriptors.h" 29 #include "device/usb/usb_descriptors.h"
30 #include "device/usb/usb_service.h" 30 #include "device/usb/usb_service.h"
31 #include "extensions/browser/extension_registry.h" 31 #include "extensions/browser/extension_registry.h"
32 #include "extensions/common/extension_builder.h" 32 #include "extensions/common/extension_builder.h"
33 #include "extensions/common/value_builder.h" 33 #include "extensions/common/value_builder.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 20 matching lines...) Expand all
55 return std::unique_ptr<KeyedService>( 55 return std::unique_ptr<KeyedService>(
56 new chromeos::PrinterDetector(Profile::FromBrowserContext(context))); 56 new chromeos::PrinterDetector(Profile::FromBrowserContext(context)));
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 // TODO(tbarzic): Rename this test. 61 // TODO(tbarzic): Rename this test.
62 class PrinterDetectorAppSearchEnabledTest : public testing::Test { 62 class PrinterDetectorAppSearchEnabledTest : public testing::Test {
63 public: 63 public:
64 PrinterDetectorAppSearchEnabledTest() 64 PrinterDetectorAppSearchEnabledTest()
65 : user_manager_(new user_manager::FakeUserManager()), 65 : user_manager_(new chromeos::FakeChromeUserManager()),
66 user_manager_enabler_(user_manager_) {} 66 user_manager_enabler_(user_manager_) {}
67 67
68 ~PrinterDetectorAppSearchEnabledTest() override = default; 68 ~PrinterDetectorAppSearchEnabledTest() override = default;
69 69
70 void SetUp() override { 70 void SetUp() override {
71 device_client_.GetUsbService(); 71 device_client_.GetUsbService();
72 // Make sure the profile is created after adding the switch and setting up 72 // Make sure the profile is created after adding the switch and setting up
73 // device client. 73 // device client.
74 profile_.reset(new TestingProfile()); 74 profile_.reset(new TestingProfile());
75 chromeos::PrinterDetectorFactory::GetInstance()->SetTestingFactoryAndUse( 75 chromeos::PrinterDetectorFactory::GetInstance()->SetTestingFactoryAndUse(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 .Build()) 128 .Build())
129 .Build()) 129 .Build())
130 .Set("permissions", std::move(permissions_builder)) 130 .Set("permissions", std::move(permissions_builder))
131 .Set("usb_printers", std::move(usb_printers_builder)) 131 .Set("usb_printers", std::move(usb_printers_builder))
132 .Build()) 132 .Build())
133 .Build(); 133 .Build();
134 } 134 }
135 135
136 content::TestBrowserThreadBundle thread_bundle_; 136 content::TestBrowserThreadBundle thread_bundle_;
137 StubNotificationUIManager notification_ui_manager_; 137 StubNotificationUIManager notification_ui_manager_;
138 user_manager::FakeUserManager* user_manager_; 138 chromeos::FakeChromeUserManager* user_manager_;
139 chromeos::ScopedUserManagerEnabler user_manager_enabler_; 139 chromeos::ScopedUserManagerEnabler user_manager_enabler_;
140 device::MockDeviceClient device_client_; 140 device::MockDeviceClient device_client_;
141 std::unique_ptr<TestingProfile> profile_; 141 std::unique_ptr<TestingProfile> profile_;
142 142
143 DISALLOW_COPY_AND_ASSIGN(PrinterDetectorAppSearchEnabledTest); 143 DISALLOW_COPY_AND_ASSIGN(PrinterDetectorAppSearchEnabledTest);
144 }; 144 };
145 145
146 TEST_F(PrinterDetectorAppSearchEnabledTest, ShowFindAppNotification) { 146 TEST_F(PrinterDetectorAppSearchEnabledTest, ShowFindAppNotification) {
147 InvokeUsbAdded(123, 456, kPrinterInterfaceClass); 147 InvokeUsbAdded(123, 456, kPrinterInterfaceClass);
148 148
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 .Build()); 336 .Build());
337 ASSERT_TRUE(extensions::ExtensionRegistry::Get(profile_.get()) 337 ASSERT_TRUE(extensions::ExtensionRegistry::Get(profile_.get())
338 ->AddEnabled(extension)); 338 ->AddEnabled(extension));
339 339
340 InvokeUsbAdded(123, 456, 1); 340 InvokeUsbAdded(123, 456, 1);
341 341
342 ASSERT_EQ(0u, notification_ui_manager_.GetNotificationCount()); 342 ASSERT_EQ(0u, notification_ui_manager_.GetNotificationCount());
343 } 343 }
344 344
345 } // namespace chromeos 345 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698