| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "public/web/WebWidgetClient.h" | 87 #include "public/web/WebWidgetClient.h" |
| 88 #include "third_party/skia/include/core/SkBitmap.h" | 88 #include "third_party/skia/include/core/SkBitmap.h" |
| 89 #include "third_party/skia/include/core/SkBitmapDevice.h" | 89 #include "third_party/skia/include/core/SkBitmapDevice.h" |
| 90 #include "third_party/skia/include/core/SkCanvas.h" | 90 #include "third_party/skia/include/core/SkCanvas.h" |
| 91 #include "web/WebLocalFrameImpl.h" | 91 #include "web/WebLocalFrameImpl.h" |
| 92 #include "web/WebSettingsImpl.h" | 92 #include "web/WebSettingsImpl.h" |
| 93 #include "web/WebViewImpl.h" | 93 #include "web/WebViewImpl.h" |
| 94 #include "web/tests/FrameTestHelpers.h" | 94 #include "web/tests/FrameTestHelpers.h" |
| 95 #include <gtest/gtest.h> | 95 #include <gtest/gtest.h> |
| 96 | 96 |
| 97 using namespace blink; | |
| 98 using blink::FrameTestHelpers::loadFrame; | 97 using blink::FrameTestHelpers::loadFrame; |
| 99 using blink::URLTestHelpers::toKURL; | 98 using blink::URLTestHelpers::toKURL; |
| 100 using blink::URLTestHelpers::registerMockedURLLoad; | 99 using blink::URLTestHelpers::registerMockedURLLoad; |
| 101 using blink::testing::runPendingTasks; | 100 using blink::testing::runPendingTasks; |
| 102 | 101 |
| 103 namespace { | 102 namespace blink { |
| 104 | 103 |
| 105 enum HorizontalScrollbarState { | 104 enum HorizontalScrollbarState { |
| 106 NoHorizontalScrollbar, | 105 NoHorizontalScrollbar, |
| 107 VisibleHorizontalScrollbar, | 106 VisibleHorizontalScrollbar, |
| 108 }; | 107 }; |
| 109 | 108 |
| 110 enum VerticalScrollbarState { | 109 enum VerticalScrollbarState { |
| 111 NoVerticalScrollbar, | 110 NoVerticalScrollbar, |
| 112 VisibleVerticalScrollbar, | 111 VisibleVerticalScrollbar, |
| 113 }; | 112 }; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 128 int height() const { return m_size.height; } | 127 int height() const { return m_size.height; } |
| 129 | 128 |
| 130 private: | 129 private: |
| 131 WebSize m_size; | 130 WebSize m_size; |
| 132 WebViewImpl* m_webView; | 131 WebViewImpl* m_webView; |
| 133 }; | 132 }; |
| 134 | 133 |
| 135 class AutoResizeWebViewClient : public FrameTestHelpers::TestWebViewClient { | 134 class AutoResizeWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 136 public: | 135 public: |
| 137 // WebViewClient methods | 136 // WebViewClient methods |
| 138 virtual void didAutoResize(const WebSize& newSize) { m_testData.setSize(newS
ize); } | 137 void didAutoResize(const WebSize& newSize) override { m_testData.setSize(new
Size); } |
| 139 | 138 |
| 140 // Local methods | 139 // Local methods |
| 141 TestData& testData() { return m_testData; } | 140 TestData& testData() { return m_testData; } |
| 142 | 141 |
| 143 private: | 142 private: |
| 144 TestData m_testData; | 143 TestData m_testData; |
| 145 }; | 144 }; |
| 146 | 145 |
| 147 class SaveImageFromDataURLWebViewClient : public FrameTestHelpers::TestWebViewCl
ient { | 146 class SaveImageFromDataURLWebViewClient : public FrameTestHelpers::TestWebViewCl
ient { |
| 148 public: | 147 public: |
| 149 // WebViewClient methods | 148 // WebViewClient methods |
| 150 virtual void saveImageFromDataURL(const WebString& dataURL) { m_dataURL = da
taURL; } | 149 void saveImageFromDataURL(const WebString& dataURL) override { m_dataURL = d
ataURL; } |
| 151 | 150 |
| 152 // Local methods | 151 // Local methods |
| 153 const WebString& result() const { return m_dataURL; } | 152 const WebString& result() const { return m_dataURL; } |
| 154 void reset() { m_dataURL = WebString(); } | 153 void reset() { m_dataURL = WebString(); } |
| 155 | 154 |
| 156 private: | 155 private: |
| 157 WebString m_dataURL; | 156 WebString m_dataURL; |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 class TapHandlingWebViewClient : public FrameTestHelpers::TestWebViewClient { | 159 class TapHandlingWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| 161 public: | 160 public: |
| 162 // WebViewClient methods | 161 // WebViewClient methods |
| 163 virtual void didHandleGestureEvent(const WebGestureEvent& event, bool eventC
ancelled) | 162 void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled
) override |
| 164 { | 163 { |
| 165 if (event.type == WebInputEvent::GestureTap) { | 164 if (event.type == WebInputEvent::GestureTap) { |
| 166 m_tapX = event.x; | 165 m_tapX = event.x; |
| 167 m_tapY = event.y; | 166 m_tapY = event.y; |
| 168 } else if (event.type == WebInputEvent::GestureLongPress) { | 167 } else if (event.type == WebInputEvent::GestureLongPress) { |
| 169 m_longpressX = event.x; | 168 m_longpressX = event.x; |
| 170 m_longpressY = event.y; | 169 m_longpressY = event.y; |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 | 172 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 197 { | 196 { |
| 198 return m_chooserCompletion; | 197 return m_chooserCompletion; |
| 199 } | 198 } |
| 200 | 199 |
| 201 void clearChooserCompletion() | 200 void clearChooserCompletion() |
| 202 { | 201 { |
| 203 m_chooserCompletion = 0; | 202 m_chooserCompletion = 0; |
| 204 } | 203 } |
| 205 | 204 |
| 206 // WebViewClient methods | 205 // WebViewClient methods |
| 207 virtual bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTim
eChooserCompletion* chooser_completion) override | 206 bool openDateTimeChooser(const WebDateTimeChooserParams&, WebDateTimeChooser
Completion* chooser_completion) override |
| 208 { | 207 { |
| 209 m_chooserCompletion = chooser_completion; | 208 m_chooserCompletion = chooser_completion; |
| 210 return true; | 209 return true; |
| 211 } | 210 } |
| 212 | 211 |
| 213 private: | 212 private: |
| 214 WebDateTimeChooserCompletion* m_chooserCompletion; | 213 WebDateTimeChooserCompletion* m_chooserCompletion; |
| 215 | 214 |
| 216 }; | 215 }; |
| 217 | 216 |
| 218 class WebViewTest : public ::testing::Test { | 217 class WebViewTest : public ::testing::Test { |
| 219 public: | 218 public: |
| 220 WebViewTest() | 219 WebViewTest() |
| 221 : m_baseURL("http://www.test.com/") | 220 : m_baseURL("http://www.test.com/") |
| 222 { | 221 { |
| 223 } | 222 } |
| 224 | 223 |
| 225 virtual void TearDown() | 224 void TearDown() override |
| 226 { | 225 { |
| 227 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 226 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 228 } | 227 } |
| 229 | 228 |
| 230 protected: | 229 protected: |
| 231 void registerMockedHttpURLLoad(const std::string& fileName) | 230 void registerMockedHttpURLLoad(const std::string& fileName) |
| 232 { | 231 { |
| 233 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 232 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 234 } | 233 } |
| 235 | 234 |
| (...skipping 2807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 ASSERT_EQ(4ul, renders.size()); | 3042 ASSERT_EQ(4ul, renders.size()); |
| 3044 for (size_t i = 0; i < renders.size(); ++i) { | 3043 for (size_t i = 0; i < renders.size(); ++i) { |
| 3045 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3044 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
| 3046 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3045 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
| 3047 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3046 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
| 3048 double docDuration = docFinishTime - docStartTime; | 3047 double docDuration = docFinishTime - docStartTime; |
| 3049 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3048 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
| 3050 } | 3049 } |
| 3051 } | 3050 } |
| 3052 | 3051 |
| 3053 } // namespace | 3052 } // namespace blink |
| OLD | NEW |