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

Side by Side Diff: content/test/mock_webclipboard_impl.cc

Issue 396953002: Add testRunner.copyAtAndCapturePixelsAsyncThen() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated patch Created 6 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 unified diff | Download patch
« no previous file with comments | « content/test/mock_webclipboard_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/test/mock_webclipboard_impl.h" 5 #include "content/test/mock_webclipboard_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 12 matching lines...) Expand all
23 using blink::WebString; 23 using blink::WebString;
24 using blink::WebURL; 24 using blink::WebURL;
25 using blink::WebVector; 25 using blink::WebVector;
26 26
27 namespace content { 27 namespace content {
28 28
29 MockWebClipboardImpl::MockWebClipboardImpl() {} 29 MockWebClipboardImpl::MockWebClipboardImpl() {}
30 30
31 MockWebClipboardImpl::~MockWebClipboardImpl() {} 31 MockWebClipboardImpl::~MockWebClipboardImpl() {}
32 32
33 uint64_t MockWebClipboardImpl::sequenceNumber(Buffer) {
34 return m_sequenceNumber;
35 }
36
33 bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) { 37 bool MockWebClipboardImpl::isFormatAvailable(Format format, Buffer buffer) {
34 switch (format) { 38 switch (format) {
35 case FormatPlainText: 39 case FormatPlainText:
36 return !m_plainText.is_null(); 40 return !m_plainText.is_null();
37 41
38 case FormatHTML: 42 case FormatHTML:
39 return !m_htmlText.is_null(); 43 return !m_htmlText.is_null();
40 44
41 case FormatSmartPaste: 45 case FormatSmartPaste:
42 return m_writeSmartPaste; 46 return m_writeSmartPaste;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 127
124 void MockWebClipboardImpl::writeHTML(const blink::WebString& htmlText, 128 void MockWebClipboardImpl::writeHTML(const blink::WebString& htmlText,
125 const blink::WebURL& url, 129 const blink::WebURL& url,
126 const blink::WebString& plainText, 130 const blink::WebString& plainText,
127 bool writeSmartPaste) { 131 bool writeSmartPaste) {
128 clear(); 132 clear();
129 133
130 m_htmlText = htmlText; 134 m_htmlText = htmlText;
131 m_plainText = plainText; 135 m_plainText = plainText;
132 m_writeSmartPaste = writeSmartPaste; 136 m_writeSmartPaste = writeSmartPaste;
137 ++m_sequenceNumber;
133 } 138 }
134 139
135 void MockWebClipboardImpl::writePlainText(const blink::WebString& plain_text) { 140 void MockWebClipboardImpl::writePlainText(const blink::WebString& plain_text) {
136 clear(); 141 clear();
137 142
138 m_plainText = plain_text; 143 m_plainText = plain_text;
144 ++m_sequenceNumber;
139 } 145 }
140 146
141 void MockWebClipboardImpl::writeURL(const blink::WebURL& url, 147 void MockWebClipboardImpl::writeURL(const blink::WebURL& url,
142 const blink::WebString& title) { 148 const blink::WebString& title) {
143 clear(); 149 clear();
144 150
145 m_htmlText = WebString::fromUTF8(URLToMarkup(url, title)); 151 m_htmlText = WebString::fromUTF8(URLToMarkup(url, title));
146 m_plainText = url.spec().utf16(); 152 m_plainText = url.spec().utf16();
153 ++m_sequenceNumber;
147 } 154 }
148 155
149 void MockWebClipboardImpl::writeImage(const blink::WebImage& image, 156 void MockWebClipboardImpl::writeImage(const blink::WebImage& image,
150 const blink::WebURL& url, 157 const blink::WebURL& url,
151 const blink::WebString& title) { 158 const blink::WebString& title) {
152 if (!image.isNull()) { 159 if (!image.isNull()) {
153 clear(); 160 clear();
154 161
155 m_plainText = m_htmlText; 162 m_plainText = m_htmlText;
156 m_htmlText = WebString::fromUTF8(URLToImageMarkup(url, title)); 163 m_htmlText = WebString::fromUTF8(URLToImageMarkup(url, title));
157 m_image = image; 164 m_image = image;
165 ++m_sequenceNumber;
158 } 166 }
159 } 167 }
160 168
161 void MockWebClipboardImpl::writeDataObject(const WebDragData& data) { 169 void MockWebClipboardImpl::writeDataObject(const WebDragData& data) {
162 clear(); 170 clear();
163 171
164 const WebVector<WebDragData::Item>& itemList = data.items(); 172 const WebVector<WebDragData::Item>& itemList = data.items();
165 for (size_t i = 0; i < itemList.size(); ++i) { 173 for (size_t i = 0; i < itemList.size(); ++i) {
166 const WebDragData::Item& item = itemList[i]; 174 const WebDragData::Item& item = itemList[i];
167 switch (item.storageType) { 175 switch (item.storageType) {
168 case WebDragData::Item::StorageTypeString: { 176 case WebDragData::Item::StorageTypeString: {
177 ++m_sequenceNumber;
169 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) { 178 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeText)) {
170 m_plainText = item.stringData; 179 m_plainText = item.stringData;
171 continue; 180 continue;
172 } 181 }
173 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) { 182 if (EqualsASCII(item.stringType, ui::Clipboard::kMimeTypeHTML)) {
174 m_htmlText = item.stringData; 183 m_htmlText = item.stringData;
175 continue; 184 continue;
176 } 185 }
177 m_customData.insert(std::make_pair(item.stringType, item.stringData)); 186 m_customData.insert(std::make_pair(item.stringType, item.stringData));
178 continue; 187 continue;
179 } 188 }
180 default: 189 default:
181 // Currently other types are unused by the clipboard implementation. 190 // Currently other types are unused by the clipboard implementation.
182 NOTREACHED(); 191 NOTREACHED();
183 } 192 }
184 } 193 }
185 } 194 }
186 195
187 void MockWebClipboardImpl::clear() { 196 void MockWebClipboardImpl::clear() {
188 m_plainText = base::NullableString16(); 197 m_plainText = base::NullableString16();
189 m_htmlText = base::NullableString16(); 198 m_htmlText = base::NullableString16();
190 m_image.reset(); 199 m_image.reset();
191 m_customData.clear(); 200 m_customData.clear();
192 m_writeSmartPaste = false; 201 m_writeSmartPaste = false;
202 m_sequenceNumber = 0;
sky 2014/07/17 21:32:31 Is there a reason why this and m_writeSmartPaste a
hj.r.chung 2014/07/18 04:00:27 I'll upload another patch with both members in the
193 } 203 }
194 204
195 } // namespace content 205 } // namespace content
OLDNEW
« no previous file with comments | « content/test/mock_webclipboard_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698