OLD | NEW |
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> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
| 11 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
11 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
14 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h" | 17 #include "chrome/browser/chromeos/printer_detector/printer_detector_factory.h" |
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
16 #include "chrome/browser/extensions/test_extension_system.h" | 19 #include "chrome/browser/extensions/test_extension_system.h" |
17 #include "chrome/browser/notifications/notification.h" | 20 #include "chrome/browser/notifications/notification.h" |
18 #include "chrome/browser/notifications/notification_test_util.h" | 21 #include "chrome/browser/notifications/notification_test_util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
30 #include "extensions/common/value_builder.h" | 33 #include "extensions/common/value_builder.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
32 | 35 |
33 using extensions::DictionaryBuilder; | 36 using extensions::DictionaryBuilder; |
34 using extensions::ListBuilder; | 37 using extensions::ListBuilder; |
35 | 38 |
36 namespace chromeos { | 39 namespace chromeos { |
37 | 40 |
38 namespace { | 41 namespace { |
39 | 42 |
40 const uint8 kPrinterInterfaceClass = 7; | 43 const uint8_t kPrinterInterfaceClass = 7; |
41 | 44 |
42 const char kTestUserId[] = "test_user"; | 45 const char kTestUserId[] = "test_user"; |
43 | 46 |
44 const char kPrinterAppExistsDelegateIDTemplate[] = | 47 const char kPrinterAppExistsDelegateIDTemplate[] = |
45 "system.printer.printer_provider_exists/%s:%s"; | 48 "system.printer.printer_provider_exists/%s:%s"; |
46 | 49 |
47 const char kPrinterAppNotFoundDelegateIDTemplate[] = | 50 const char kPrinterAppNotFoundDelegateIDTemplate[] = |
48 "system.printer.no_printer_provider_found/%s:%s"; | 51 "system.printer.no_printer_provider_found/%s:%s"; |
49 | 52 |
50 class FakeDeviceClient : public device::DeviceClient { | 53 class FakeDeviceClient : public device::DeviceClient { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 const user_manager::User* user = | 111 const user_manager::User* user = |
109 user_manager_->AddUser(AccountId::FromUserEmail(kTestUserId)); | 112 user_manager_->AddUser(AccountId::FromUserEmail(kTestUserId)); |
110 profile_->set_profile_name(kTestUserId); | 113 profile_->set_profile_name(kTestUserId); |
111 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting( | 114 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting( |
112 user, profile_.get()); | 115 user, profile_.get()); |
113 chromeos::PrinterDetectorFactory::GetInstance() | 116 chromeos::PrinterDetectorFactory::GetInstance() |
114 ->Get(profile_.get()) | 117 ->Get(profile_.get()) |
115 ->SetNotificationUIManagerForTesting(¬ification_ui_manager_); | 118 ->SetNotificationUIManagerForTesting(¬ification_ui_manager_); |
116 } | 119 } |
117 | 120 |
118 void InvokeUsbAdded(uint16 vendor_id, | 121 void InvokeUsbAdded(uint16_t vendor_id, |
119 uint16 product_id, | 122 uint16_t product_id, |
120 uint8 interface_class) { | 123 uint8_t interface_class) { |
121 device::UsbInterfaceDescriptor interface; | 124 device::UsbInterfaceDescriptor interface; |
122 interface.interface_number = 1; | 125 interface.interface_number = 1; |
123 interface.interface_class = interface_class; | 126 interface.interface_class = interface_class; |
124 device::UsbConfigDescriptor config; | 127 device::UsbConfigDescriptor config; |
125 config.interfaces.push_back(interface); | 128 config.interfaces.push_back(interface); |
126 usb_service_.AddDevice( | 129 usb_service_.AddDevice( |
127 new device::MockUsbDevice(vendor_id, product_id, config)); | 130 new device::MockUsbDevice(vendor_id, product_id, config)); |
128 } | 131 } |
129 | 132 |
130 // Creates a test extension with the provided permissions. | 133 // Creates a test extension with the provided permissions. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 .Set("interfaceClass", kPrinterInterfaceClass))))))); | 331 .Set("interfaceClass", kPrinterInterfaceClass))))))); |
329 ASSERT_TRUE(extensions::ExtensionRegistry::Get(profile_.get()) | 332 ASSERT_TRUE(extensions::ExtensionRegistry::Get(profile_.get()) |
330 ->AddEnabled(extension)); | 333 ->AddEnabled(extension)); |
331 | 334 |
332 InvokeUsbAdded(123, 456, 1); | 335 InvokeUsbAdded(123, 456, 1); |
333 | 336 |
334 ASSERT_EQ(0u, notification_ui_manager_.GetNotificationCount()); | 337 ASSERT_EQ(0u, notification_ui_manager_.GetNotificationCount()); |
335 } | 338 } |
336 | 339 |
337 } // namespace chromeos | 340 } // namespace chromeos |
OLD | NEW |