| OLD | NEW |
| 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 // This file mocks out just enough of the WebClipboard API for running the | 5 // This file mocks out just enough of the WebClipboard API for running the |
| 6 // webkit tests. This is so we can run webkit tests without them sharing a | 6 // webkit tests. This is so we can run webkit tests without them sharing a |
| 7 // clipboard, which allows for running them in parallel and having the tests | 7 // clipboard, which allows for running them in parallel and having the tests |
| 8 // not interact with actual user actions. | 8 // not interact with actual user actions. |
| 9 | 9 |
| 10 #ifndef CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ | 10 #ifndef CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ |
| 11 #define CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ | 11 #define CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ |
| 12 | 12 |
| 13 #include <stdint.h> | 13 #include <stdint.h> |
| 14 | 14 |
| 15 #include <map> | 15 #include <map> |
| 16 | 16 |
| 17 #include "base/strings/nullable_string16.h" | 17 #include "base/strings/nullable_string16.h" |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "third_party/WebKit/public/platform/WebClipboard.h" | |
| 20 #include "third_party/WebKit/public/platform/WebDragData.h" | 19 #include "third_party/WebKit/public/platform/WebDragData.h" |
| 21 #include "third_party/WebKit/public/platform/WebImage.h" | 20 #include "third_party/WebKit/public/platform/WebImage.h" |
| 21 #include "third_party/WebKit/public/platform/WebMockClipboard.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 class MockWebClipboardImpl : public blink::WebClipboard { | 25 class MockWebClipboardImpl : public blink::WebMockClipboard { |
| 26 public: | 26 public: |
| 27 MockWebClipboardImpl(); | 27 MockWebClipboardImpl(); |
| 28 virtual ~MockWebClipboardImpl(); | 28 virtual ~MockWebClipboardImpl(); |
| 29 | 29 |
| 30 uint64_t sequenceNumber(Buffer) override; | 30 uint64_t sequenceNumber(Buffer) override; |
| 31 bool isFormatAvailable(blink::WebClipboard::Format format, | 31 bool isFormatAvailable(blink::WebClipboard::Format format, |
| 32 blink::WebClipboard::Buffer buffer) override; | 32 blink::WebClipboard::Buffer buffer) override; |
| 33 blink::WebVector<blink::WebString> readAvailableTypes( | 33 blink::WebVector<blink::WebString> readAvailableTypes( |
| 34 blink::WebClipboard::Buffer buffer, | 34 blink::WebClipboard::Buffer buffer, |
| 35 bool* containsFilenames) override; | 35 bool* containsFilenames) override; |
| 36 | 36 |
| 37 blink::WebString readPlainText(blink::WebClipboard::Buffer buffer) override; | 37 blink::WebString readPlainText(blink::WebClipboard::Buffer buffer) override; |
| 38 blink::WebString readHTML(blink::WebClipboard::Buffer buffer, | 38 blink::WebString readHTML(blink::WebClipboard::Buffer buffer, |
| 39 blink::WebURL* url, | 39 blink::WebURL* url, |
| 40 unsigned* fragmentStart, | 40 unsigned* fragmentStart, |
| 41 unsigned* fragmentEnd) override; | 41 unsigned* fragmentEnd) override; |
| 42 blink::WebData readImage(blink::WebClipboard::Buffer buffer) override; | 42 blink::WebBlobInfo readImage(blink::WebClipboard::Buffer buffer) override; |
| 43 blink::WebImage readRawImage(blink::WebClipboard::Buffer buffer) override; |
| 43 blink::WebString readCustomData(blink::WebClipboard::Buffer buffer, | 44 blink::WebString readCustomData(blink::WebClipboard::Buffer buffer, |
| 44 const blink::WebString& type) override; | 45 const blink::WebString& type) override; |
| 45 | 46 |
| 46 void writePlainText(const blink::WebString& plain_text) override; | 47 void writePlainText(const blink::WebString& plain_text) override; |
| 47 void writeHTML(const blink::WebString& htmlText, | 48 void writeHTML(const blink::WebString& htmlText, |
| 48 const blink::WebURL& url, | 49 const blink::WebURL& url, |
| 49 const blink::WebString& plainText, | 50 const blink::WebString& plainText, |
| 50 bool writeSmartPaste) override; | 51 bool writeSmartPaste) override; |
| 51 virtual void writeURL( | 52 virtual void writeURL( |
| 52 const blink::WebURL& url, const blink::WebString& title); | 53 const blink::WebURL& url, const blink::WebString& title); |
| 53 void writeImage(const blink::WebImage& image, | 54 void writeImage(const blink::WebImage& image, |
| 54 const blink::WebURL& url, | 55 const blink::WebURL& url, |
| 55 const blink::WebString& title) override; | 56 const blink::WebString& title) override; |
| 56 void writeDataObject(const blink::WebDragData& data) override; | 57 void writeDataObject(const blink::WebDragData& data) override; |
| 57 | 58 |
| 58 private: | 59 private: |
| 59 void clear(); | 60 void clear(); |
| 60 | 61 |
| 61 uint64_t m_sequenceNumber; | 62 uint64_t m_sequenceNumber; |
| 62 base::NullableString16 m_plainText; | 63 base::NullableString16 m_plainText; |
| 63 base::NullableString16 m_htmlText; | 64 base::NullableString16 m_htmlText; |
| 64 blink::WebImage m_image; | 65 blink::WebImage m_image; |
| 65 std::map<base::string16, base::string16> m_customData; | 66 std::map<base::string16, base::string16> m_customData; |
| 66 bool m_writeSmartPaste; | 67 bool m_writeSmartPaste; |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 } // namespace content | 70 } // namespace content |
| 70 | 71 |
| 71 #endif // CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ | 72 #endif // CONTENT_TEST_MOCK_WEBCLIPBOARD_IMPL_H_ |
| OLD | NEW |