Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
|
Ken Rockot(use gerrit already)
2017/07/25 05:02:06
nit: maybe test_service_main.cc would make more se
Wei Li
2017/07/26 05:08:50
More meaningful, done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/test/test_discardable_memory_allocator.h" | |
| 6 #include "components/printing/service/pdf_compositor_service.h" | |
| 7 #include "services/service_manager/public/c/main.h" | |
| 8 #include "services/service_manager/public/cpp/service_runner.h" | |
| 9 | |
| 10 // In order to test PdfCompositorService, this class overrides and | |
| 11 // uses a test discardable memory allocator. | |
| 12 class PdfCompositorTestService : public printing::PdfCompositorService { | |
| 13 public: | |
| 14 explicit PdfCompositorTestService(const std::string& creator) | |
| 15 : PdfCompositorService(creator) {} | |
| 16 ~PdfCompositorTestService() override {} | |
| 17 | |
| 18 // PdfCompositorService: | |
| 19 void PrepareToStart() override; | |
| 20 }; | |
| 21 | |
| 22 void PdfCompositorTestService::PrepareToStart() { | |
| 23 base::TestDiscardableMemoryAllocator mem_allocator; | |
| 24 base::DiscardableMemoryAllocator::SetInstance(&mem_allocator); | |
| 25 } | |
| 26 | |
| 27 MojoResult ServiceMain(MojoHandle service_request_handle) { | |
| 28 service_manager::ServiceRunner runner( | |
| 29 new PdfCompositorTestService("pdf_compositor_service_unittest")); | |
| 30 return runner.Run(service_request_handle); | |
| 31 } | |
| OLD | NEW |