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

Unified Diff: components/printing/service/test_service_main.cc

Issue 2919823004: Add error handling and unit test for pdf compositor service (Closed)
Patch Set: rebase Created 3 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: components/printing/service/test_service_main.cc
diff --git a/components/printing/service/test_service_main.cc b/components/printing/service/test_service_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd8b2c464c3381e723a07d23b2ffc050a2435827
--- /dev/null
+++ b/components/printing/service/test_service_main.cc
@@ -0,0 +1,33 @@
+// Copyright 2017 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 "base/test/test_discardable_memory_allocator.h"
+#include "components/printing/service/pdf_compositor_service.h"
+#include "services/service_manager/public/c/main.h"
+#include "services/service_manager/public/cpp/service_runner.h"
+
+// In order to test PdfCompositorService, this class overrides and
+// uses a test discardable memory allocator.
+class PdfCompositorTestService : public printing::PdfCompositorService {
+ public:
+ explicit PdfCompositorTestService(const std::string& creator)
+ : PdfCompositorService(creator) {}
+ ~PdfCompositorTestService() override {}
+
+ // PdfCompositorService:
+ void PrepareToStart() override;
+
+ private:
+ base::TestDiscardableMemoryAllocator mem_allocator_;
+};
+
+void PdfCompositorTestService::PrepareToStart() {
+ base::DiscardableMemoryAllocator::SetInstance(&mem_allocator_);
+}
+
+MojoResult ServiceMain(MojoHandle service_request_handle) {
+ service_manager::ServiceRunner runner(
+ new PdfCompositorTestService("pdf_compositor_service_unittest"));
+ return runner.Run(service_request_handle);
+}
« no previous file with comments | « components/printing/service/public/interfaces/pdf_compositor.mojom ('k') | components/test/data/printing/google.mskp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698