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
ash / webui / print_preview_cros / backend / destination_provider_unittest.cc [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/webui/print_preview_cros/backend/destination_provider.h"
#include "ash/webui/print_preview_cros/mojom/destination_provider.mojom.h"
#include "ash/webui/print_preview_cros/mojom/printer_capabilities.mojom.h"
#include "base/functional/callback_helpers.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "printing/mojom/print.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash::printing::print_preview {
class DestinationProviderTest : public testing::Test {
public:
DestinationProviderTest() = default;
~DestinationProviderTest() override = default;
// testing::Test:
void SetUp() override {
destination_provider_.BindInterface(
destination_provider_remote_.BindNewPipeAndPassReceiver());
destination_provider_remote_.FlushForTesting();
}
mojom::CapabilitiesPtr FetchCapabilities(
const std::string& destination_id,
::printing::mojom::PrinterType printer_type) {
base::test::TestFuture<mojom::CapabilitiesPtr> future;
destination_provider_remote_->FetchCapabilities(
destination_id, printer_type, future.GetCallback());
return future.Take();
}
protected:
base::test::TaskEnvironment task_environment_;
DestinationProvider destination_provider_;
mojo::Remote<mojom::DestinationProvider> destination_provider_remote_;
};
// Verify requesting PDF printing capabilities returns the expected default
// settings.
TEST_F(DestinationProviderTest, FetchPdfCapabilities) {
const std::string destination_id = "PDF_printer";
const mojom::CapabilitiesPtr caps =
FetchCapabilities(destination_id, ::printing::mojom::PrinterType::kPdf);
EXPECT_EQ(destination_id, caps->destination_id);
EXPECT_FALSE(caps->page_orientation->options.empty());
EXPECT_FALSE(caps->color->options.empty());
EXPECT_FALSE(caps->media_size->options.empty());
EXPECT_FALSE(caps->dpi->options.empty());
}
} // namespace ash::printing::print_preview