forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_print_backend.cc
87 lines (67 loc) · 2.41 KB
/
test_print_backend.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "printing/backend/test_print_backend.h"
#include <memory>
#include <utility>
#include "base/stl_util.h"
#include "printing/backend/print_backend.h"
namespace printing {
TestPrintBackend::TestPrintBackend() : PrintBackend(/*locale=*/std::string()) {}
TestPrintBackend::~TestPrintBackend() = default;
bool TestPrintBackend::EnumeratePrinters(PrinterList* printer_list) {
if (printer_list_.empty())
return false;
printer_list->insert(printer_list->end(), printer_list_.begin(),
printer_list_.end());
return true;
}
std::string TestPrintBackend::GetDefaultPrinterName() {
return default_printer_name_;
}
bool TestPrintBackend::GetPrinterBasicInfo(const std::string& printer_name,
PrinterBasicInfo* printer_info) {
NOTREACHED() << "Not implemented";
return false;
}
bool TestPrintBackend::GetPrinterSemanticCapsAndDefaults(
const std::string& printer_name,
PrinterSemanticCapsAndDefaults* printer_info) {
auto found = valid_printers_.find(printer_name);
if (found == valid_printers_.end())
return false;
const std::unique_ptr<PrinterSemanticCapsAndDefaults>& caps = found->second;
if (!caps)
return false;
*printer_info = *(found->second);
return true;
}
#if !defined(OS_CHROMEOS)
bool TestPrintBackend::GetPrinterCapsAndDefaults(
const std::string& printer_name,
PrinterCapsAndDefaults* printer_info) {
// not implemented
return false;
}
#endif // !defined(OS_CHROMEOS)
std::string TestPrintBackend::GetPrinterDriverInfo(
const std::string& printr_name) {
// not implemented
return "";
}
bool TestPrintBackend::IsValidPrinter(const std::string& printer_name) {
return base::Contains(valid_printers_, printer_name);
}
void TestPrintBackend::PopulatePrinterList(const PrinterList& printer_list) {
printer_list_.insert(printer_list_.end(), printer_list.begin(),
printer_list.end());
}
void TestPrintBackend::SetDefaultPrinterName(const std::string& printer_name) {
default_printer_name_ = printer_name;
}
void TestPrintBackend::AddValidPrinter(
const std::string& printer_name,
std::unique_ptr<PrinterSemanticCapsAndDefaults> caps) {
valid_printers_[printer_name] = std::move(caps);
}
} // namespace printing