OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/printing/printers_manager.h" | 5 #include "chrome/browser/chromeos/printing/printers_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/debug/dump_without_crashing.h" | 11 #include "base/debug/dump_without_crashing.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/optional.h" | 13 #include "base/optional.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/time/time.h" |
15 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" | 16 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
16 #include "chrome/browser/chromeos/printing/printers_sync_bridge.h" | 17 #include "chrome/browser/chromeos/printing/printers_sync_bridge.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
19 #include "components/sync/model/fake_model_type_change_processor.h" | 20 #include "components/sync/model/fake_model_type_change_processor.h" |
20 #include "components/sync/model/model_type_store.h" | 21 #include "components/sync/model/model_type_store.h" |
21 #include "components/sync_preferences/testing_pref_service_syncable.h" | 22 #include "components/sync_preferences/testing_pref_service_syncable.h" |
22 #include "content/public/test/test_browser_thread_bundle.h" | 23 #include "content/public/test/test_browser_thread_bundle.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 auto printers = manager_->GetRecommendedPrinters(); | 219 auto printers = manager_->GetRecommendedPrinters(); |
219 | 220 |
220 const Printer& from_list = *(printers.front()); | 221 const Printer& from_list = *(printers.front()); |
221 std::unique_ptr<Printer> retrieved = manager_->GetPrinter(from_list.id()); | 222 std::unique_ptr<Printer> retrieved = manager_->GetPrinter(from_list.id()); |
222 | 223 |
223 EXPECT_EQ(from_list.id(), retrieved->id()); | 224 EXPECT_EQ(from_list.id(), retrieved->id()); |
224 EXPECT_EQ("LexaPrint", from_list.display_name()); | 225 EXPECT_EQ("LexaPrint", from_list.display_name()); |
225 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source()); | 226 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source()); |
226 } | 227 } |
227 | 228 |
| 229 TEST_F(PrintersManagerTest, PrinterNotInstalled) { |
| 230 Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); |
| 231 EXPECT_FALSE(manager_->IsConfigurationCurrent(printer)); |
| 232 } |
| 233 |
| 234 TEST_F(PrintersManagerTest, PrinterIsInstalled) { |
| 235 Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); |
| 236 manager_->PrinterInstalled(printer); |
| 237 EXPECT_TRUE(manager_->IsConfigurationCurrent(printer)); |
| 238 } |
| 239 |
| 240 TEST_F(PrintersManagerTest, UpdatedPrinterConfiguration) { |
| 241 Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); |
| 242 manager_->PrinterInstalled(printer); |
| 243 |
| 244 Printer updated_printer(kPrinterId, base::Time::FromInternalValue(2000)); |
| 245 EXPECT_FALSE(manager_->IsConfigurationCurrent(updated_printer)); |
| 246 } |
| 247 |
228 } // namespace chromeos | 248 } // namespace chromeos |
OLD | NEW |