OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 addResource("http://www.test.com/red_background.png", "image/png", "red_
background.png"); | 133 addResource("http://www.test.com/red_background.png", "image/png", "red_
background.png"); |
134 addResource("http://www.test.com/orange_background.png", "image/png", "o
range_background.png"); | 134 addResource("http://www.test.com/orange_background.png", "image/png", "o
range_background.png"); |
135 addResource("http://www.test.com/yellow_background.png", "image/png", "y
ellow_background.png"); | 135 addResource("http://www.test.com/yellow_background.png", "image/png", "y
ellow_background.png"); |
136 addResource("http://www.test.com/green_background.png", "image/png", "gr
een_background.png"); | 136 addResource("http://www.test.com/green_background.png", "image/png", "gr
een_background.png"); |
137 addResource("http://www.test.com/blue_background.png", "image/png", "blu
e_background.png"); | 137 addResource("http://www.test.com/blue_background.png", "image/png", "blu
e_background.png"); |
138 addResource("http://www.test.com/purple_background.png", "image/png", "p
urple_background.png"); | 138 addResource("http://www.test.com/purple_background.png", "image/png", "p
urple_background.png"); |
139 addResource("http://www.test.com/ul-dot.png", "image/png", "ul-dot.png")
; | 139 addResource("http://www.test.com/ul-dot.png", "image/png", "ul-dot.png")
; |
140 addResource("http://www.test.com/ol-dot.png", "image/png", "ol-dot.png")
; | 140 addResource("http://www.test.com/ol-dot.png", "image/png", "ol-dot.png")
; |
141 } | 141 } |
142 | 142 |
| 143 static PassRefPtr<SharedBuffer> generateMHTMLData( |
| 144 const Vector<SerializedResource>& resources, |
| 145 MHTMLArchive::EncodingPolicy encodingPolicy, |
| 146 const String& title, const String& mimeType) |
| 147 { |
| 148 String boundary = MHTMLArchive::generateMHTMLBoundary(); |
| 149 |
| 150 RefPtr<SharedBuffer> mhtmlData = SharedBuffer::create(); |
| 151 MHTMLArchive::generateMHTMLHeader(boundary, title, mimeType, *mhtmlData)
; |
| 152 for (const auto& resource : resources) { |
| 153 MHTMLArchive::generateMHTMLPart( |
| 154 boundary, encodingPolicy, resource, *mhtmlData); |
| 155 } |
| 156 MHTMLArchive::generateMHTMLFooter(boundary, *mhtmlData); |
| 157 return mhtmlData.release(); |
| 158 } |
| 159 |
143 PassRefPtr<SharedBuffer> serialize(const char *title, const char *mime, MHT
MLArchive::EncodingPolicy encodingPolicy) | 160 PassRefPtr<SharedBuffer> serialize(const char *title, const char *mime, MHT
MLArchive::EncodingPolicy encodingPolicy) |
144 { | 161 { |
145 return MHTMLArchive::generateMHTMLData(m_resources, encodingPolicy, titl
e, mime); | 162 return generateMHTMLData(m_resources, encodingPolicy, title, mime); |
146 } | 163 } |
147 | 164 |
148 private: | 165 private: |
149 PassRefPtr<SharedBuffer> readFile(const char* fileName) | 166 PassRefPtr<SharedBuffer> readFile(const char* fileName) |
150 { | 167 { |
151 String filePath = m_filePath + fileName; | 168 String filePath = m_filePath + fileName; |
152 return Platform::current()->unitTestSupport()->readFromFile(filePath); | 169 return Platform::current()->unitTestSupport()->readFromFile(filePath); |
153 } | 170 } |
154 | 171 |
155 String m_filePath; | 172 String m_filePath; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ASSERT_TRUE(expectedEncoding); | 225 ASSERT_TRUE(expectedEncoding); |
209 EXPECT_NE(line.find(expectedEncoding), std::string::npos); | 226 EXPECT_NE(line.find(expectedEncoding), std::string::npos); |
210 expectedEncoding = 0; | 227 expectedEncoding = 0; |
211 sectionCheckedCount++; | 228 sectionCheckedCount++; |
212 } | 229 } |
213 } | 230 } |
214 EXPECT_EQ(12, sectionCheckedCount); | 231 EXPECT_EQ(12, sectionCheckedCount); |
215 } | 232 } |
216 | 233 |
217 } // namespace blink | 234 } // namespace blink |
OLD | NEW |