| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ | 5 #ifndef COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ |
| 6 #define COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ | 6 #define COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/basictypes.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 15 #include "printing/image.h" | 17 #include "printing/image.h" |
| 16 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" | 18 #include "third_party/WebKit/public/web/WebPrintScalingOption.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| 19 | 21 |
| 20 struct PrintMsg_Print_Params; | 22 struct PrintMsg_Print_Params; |
| 21 struct PrintMsg_PrintPages_Params; | 23 struct PrintMsg_PrintPages_Params; |
| 22 struct PrintHostMsg_DidPrintPage_Params; | 24 struct PrintHostMsg_DidPrintPage_Params; |
| 23 | 25 |
| 24 // A class which represents an output page used in the MockPrinter class. | 26 // A class which represents an output page used in the MockPrinter class. |
| 25 // The MockPrinter class stores output pages in a vector, so, this class | 27 // The MockPrinter class stores output pages in a vector, so, this class |
| 26 // inherits the base::RefCounted<> class so that the MockPrinter class can use | 28 // inherits the base::RefCounted<> class so that the MockPrinter class can use |
| 27 // a smart pointer of this object (i.e. scoped_refptr<>). | 29 // a smart pointer of this object (i.e. scoped_refptr<>). |
| 28 class MockPrinterPage : public base::RefCounted<MockPrinterPage> { | 30 class MockPrinterPage : public base::RefCounted<MockPrinterPage> { |
| 29 public: | 31 public: |
| 30 MockPrinterPage(const void* source_data, | 32 MockPrinterPage(const void* source_data, |
| 31 uint32 source_size, | 33 uint32_t source_size, |
| 32 const printing::Image& image); | 34 const printing::Image& image); |
| 33 | 35 |
| 34 int width() const { return image_.size().width(); } | 36 int width() const { return image_.size().width(); } |
| 35 int height() const { return image_.size().height(); } | 37 int height() const { return image_.size().height(); } |
| 36 const uint8* source_data() const { return source_data_.get(); } | 38 const uint8_t* source_data() const { return source_data_.get(); } |
| 37 uint32 source_size() const { return source_size_; } | 39 uint32_t source_size() const { return source_size_; } |
| 38 const printing::Image& image() const { return image_; } | 40 const printing::Image& image() const { return image_; } |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 friend class base::RefCounted<MockPrinterPage>; | 43 friend class base::RefCounted<MockPrinterPage>; |
| 42 virtual ~MockPrinterPage(); | 44 virtual ~MockPrinterPage(); |
| 43 | 45 |
| 44 uint32 source_size_; | 46 uint32_t source_size_; |
| 45 scoped_ptr<uint8[]> source_data_; | 47 scoped_ptr<uint8_t[]> source_data_; |
| 46 printing::Image image_; | 48 printing::Image image_; |
| 47 | 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(MockPrinterPage); | 50 DISALLOW_COPY_AND_ASSIGN(MockPrinterPage); |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 // A class which implements a pseudo-printer object used by the RenderViewTest | 53 // A class which implements a pseudo-printer object used by the RenderViewTest |
| 52 // class. | 54 // class. |
| 53 // This class consists of three parts: | 55 // This class consists of three parts: |
| 54 // 1. An IPC-message hanlder sent from the RenderView class; | 56 // 1. An IPC-message hanlder sent from the RenderView class; |
| 55 // 2. A renderer that creates a printing job into bitmaps, and; | 57 // 2. A renderer that creates a printing job into bitmaps, and; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 Status GetPrinterStatus() const { return printer_status_; } | 93 Status GetPrinterStatus() const { return printer_status_; } |
| 92 int GetPrintedPages() const; | 94 int GetPrintedPages() const; |
| 93 | 95 |
| 94 // Get a pointer to the printed page, returns NULL if pageno has not been | 96 // Get a pointer to the printed page, returns NULL if pageno has not been |
| 95 // printed. The pointer is for read only view and should not be deleted. | 97 // printed. The pointer is for read only view and should not be deleted. |
| 96 const MockPrinterPage* GetPrintedPage(unsigned int pageno) const; | 98 const MockPrinterPage* GetPrintedPage(unsigned int pageno) const; |
| 97 | 99 |
| 98 int GetWidth(unsigned int page) const; | 100 int GetWidth(unsigned int page) const; |
| 99 int GetHeight(unsigned int page) const; | 101 int GetHeight(unsigned int page) const; |
| 100 bool GetBitmapChecksum(unsigned int page, std::string* checksum) const; | 102 bool GetBitmapChecksum(unsigned int page, std::string* checksum) const; |
| 101 bool GetSource(unsigned int page, const void** data, uint32* size) const; | 103 bool GetSource(unsigned int page, const void** data, uint32_t* size) const; |
| 102 bool GetBitmap(unsigned int page, const void** data, uint32* size) const; | 104 bool GetBitmap(unsigned int page, const void** data, uint32_t* size) const; |
| 103 bool SaveSource(unsigned int page, const base::FilePath& filepath) const; | 105 bool SaveSource(unsigned int page, const base::FilePath& filepath) const; |
| 104 bool SaveBitmap(unsigned int page, const base::FilePath& filepath) const; | 106 bool SaveBitmap(unsigned int page, const base::FilePath& filepath) const; |
| 105 | 107 |
| 106 protected: | 108 protected: |
| 107 int CreateDocumentCookie(); | 109 int CreateDocumentCookie(); |
| 108 | 110 |
| 109 private: | 111 private: |
| 110 // Helper function to fill the fields in |params|. | 112 // Helper function to fill the fields in |params|. |
| 111 void SetPrintParams(PrintMsg_Print_Params* params); | 113 void SetPrintParams(PrintMsg_Print_Params* params); |
| 112 | 114 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 160 |
| 159 // Used for generating invalid settings. | 161 // Used for generating invalid settings. |
| 160 bool use_invalid_settings_; | 162 bool use_invalid_settings_; |
| 161 | 163 |
| 162 std::vector<scoped_refptr<MockPrinterPage>> pages_; | 164 std::vector<scoped_refptr<MockPrinterPage>> pages_; |
| 163 | 165 |
| 164 DISALLOW_COPY_AND_ASSIGN(MockPrinter); | 166 DISALLOW_COPY_AND_ASSIGN(MockPrinter); |
| 165 }; | 167 }; |
| 166 | 168 |
| 167 #endif // COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ | 169 #endif // COMPONENTS_PRINTING_TEST_MOCK_PRINTER_H_ |
| OLD | NEW |