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 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3042 "border: 2px solid skyblue; float: left; width: 190px; height: 30px; " | 3042 "border: 2px solid skyblue; float: left; width: 190px; height: 30px; " |
3043 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " | 3043 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " |
3044 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " | 3044 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " |
3045 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " | 3045 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " |
3046 "start; text-indent: 0px; text-transform: none; white-space: normal; " | 3046 "start; text-indent: 0px; text-transform: none; white-space: normal; " |
3047 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " | 3047 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " |
3048 "text-decoration-style: initial; text-decoration-color: initial;\">Price " | 3048 "text-decoration-style: initial; text-decoration-color: initial;\">Price " |
3049 "10,000,000won</div>"; | 3049 "10,000,000won</div>"; |
3050 WebString clipText; | 3050 WebString clipText; |
3051 WebString clipHtml; | 3051 WebString clipHtml; |
3052 WebRect clipRect; | |
3053 registerMockedHttpURLLoad("Ahem.ttf"); | 3052 registerMockedHttpURLLoad("Ahem.ttf"); |
3054 registerMockedHttpURLLoad("smartclip.html"); | 3053 registerMockedHttpURLLoad("smartclip.html"); |
3055 WebView* webView = | 3054 WebViewImpl* webView = |
3056 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); | 3055 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); |
3057 webView->resize(WebSize(500, 500)); | 3056 webView->resize(WebSize(500, 500)); |
3058 webView->updateAllLifecyclePhases(); | 3057 webView->updateAllLifecyclePhases(); |
3059 WebRect cropRect(300, 125, 152, 50); | 3058 WebRect cropRect(300, 125, 152, 50); |
3060 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 3059 webView->mainFrameImpl()->extractSmartClipData(cropRect, clipText, clipHtml); |
3061 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); | 3060 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); |
3062 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); | 3061 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); |
3063 } | 3062 } |
3064 | 3063 |
3065 TEST_P(WebViewTest, SmartClipDataWithPinchZoom) { | 3064 TEST_P(WebViewTest, SmartClipDataWithPinchZoom) { |
3066 static const char kExpectedClipText[] = "\nPrice 10,000,000won"; | 3065 static const char kExpectedClipText[] = "\nPrice 10,000,000won"; |
3067 static const char kExpectedClipHtml[] = | 3066 static const char kExpectedClipHtml[] = |
3068 "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px " | 3067 "<div id=\"div4\" style=\"padding: 10px; margin: 10px; border: 2px " |
3069 "solid skyblue; float: left; width: 190px; height: 30px; " | 3068 "solid skyblue; float: left; width: 190px; height: 30px; " |
3070 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " | 3069 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " |
3071 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " | 3070 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " |
3072 "font-weight: normal; letter-spacing: " | 3071 "font-weight: normal; letter-spacing: " |
3073 "normal; orphans: 2; text-align: start; " | 3072 "normal; orphans: 2; text-align: start; " |
3074 "text-indent: 0px; text-transform: none; white-space: normal; widows: " | 3073 "text-indent: 0px; text-transform: none; white-space: normal; widows: " |
3075 "2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " | 3074 "2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " |
3076 "text-decoration-style: initial; text-decoration-color: initial;\">Air " | 3075 "text-decoration-style: initial; text-decoration-color: initial;\">Air " |
3077 "conditioner</div><div id=\"div5\" style=\"padding: 10px; margin: 10px; " | 3076 "conditioner</div><div id=\"div5\" style=\"padding: 10px; margin: 10px; " |
3078 "border: 2px solid skyblue; float: left; width: 190px; height: 30px; " | 3077 "border: 2px solid skyblue; float: left; width: 190px; height: 30px; " |
3079 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " | 3078 "color: rgb(0, 0, 0); font-family: myahem; font-size: 8px; font-style: " |
3080 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " | 3079 "normal; font-variant-ligatures: normal; font-variant-caps: normal; " |
3081 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " | 3080 "font-weight: normal; letter-spacing: normal; orphans: 2; text-align: " |
3082 "start; text-indent: 0px; text-transform: none; white-space: normal; " | 3081 "start; text-indent: 0px; text-transform: none; white-space: normal; " |
3083 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " | 3082 "widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; " |
3084 "text-decoration-style: initial; text-decoration-color: initial;\">Price " | 3083 "text-decoration-style: initial; text-decoration-color: initial;\">Price " |
3085 "10,000,000won</div>"; | 3084 "10,000,000won</div>"; |
3086 WebString clipText; | 3085 WebString clipText; |
3087 WebString clipHtml; | 3086 WebString clipHtml; |
3088 WebRect clipRect; | |
3089 registerMockedHttpURLLoad("Ahem.ttf"); | 3087 registerMockedHttpURLLoad("Ahem.ttf"); |
3090 registerMockedHttpURLLoad("smartclip.html"); | 3088 registerMockedHttpURLLoad("smartclip.html"); |
3091 WebView* webView = | 3089 WebViewImpl* webView = |
3092 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); | 3090 m_webViewHelper.initializeAndLoad(m_baseURL + "smartclip.html"); |
3093 webView->resize(WebSize(500, 500)); | 3091 webView->resize(WebSize(500, 500)); |
3094 webView->updateAllLifecyclePhases(); | 3092 webView->updateAllLifecyclePhases(); |
3095 webView->setPageScaleFactor(1.5); | 3093 webView->setPageScaleFactor(1.5); |
3096 webView->setVisualViewportOffset(WebFloatPoint(167, 100)); | 3094 webView->setVisualViewportOffset(WebFloatPoint(167, 100)); |
3097 WebRect cropRect(200, 38, 228, 75); | 3095 WebRect cropRect(200, 38, 228, 75); |
3098 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 3096 webView->mainFrameImpl()->extractSmartClipData(cropRect, clipText, clipHtml); |
3099 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); | 3097 EXPECT_STREQ(kExpectedClipText, clipText.utf8().c_str()); |
3100 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); | 3098 EXPECT_STREQ(kExpectedClipHtml, clipHtml.utf8().c_str()); |
3101 } | 3099 } |
3102 | 3100 |
3103 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) { | 3101 TEST_P(WebViewTest, SmartClipReturnsEmptyStringsWhenUserSelectIsNone) { |
3104 WebString clipText; | 3102 WebString clipText; |
3105 WebString clipHtml; | 3103 WebString clipHtml; |
3106 WebRect clipRect; | |
3107 registerMockedHttpURLLoad("Ahem.ttf"); | 3104 registerMockedHttpURLLoad("Ahem.ttf"); |
3108 registerMockedHttpURLLoad("smartclip_user_select_none.html"); | 3105 registerMockedHttpURLLoad("smartclip_user_select_none.html"); |
3109 WebView* webView = m_webViewHelper.initializeAndLoad( | 3106 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
3110 m_baseURL + "smartclip_user_select_none.html"); | 3107 m_baseURL + "smartclip_user_select_none.html"); |
3111 webView->resize(WebSize(500, 500)); | 3108 webView->resize(WebSize(500, 500)); |
3112 webView->updateAllLifecyclePhases(); | 3109 webView->updateAllLifecyclePhases(); |
3113 WebRect cropRect(0, 0, 100, 100); | 3110 WebRect cropRect(0, 0, 100, 100); |
3114 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 3111 webView->mainFrameImpl()->extractSmartClipData(cropRect, clipText, clipHtml); |
3115 EXPECT_STREQ("", clipText.utf8().c_str()); | 3112 EXPECT_STREQ("", clipText.utf8().c_str()); |
3116 EXPECT_STREQ("", clipHtml.utf8().c_str()); | 3113 EXPECT_STREQ("", clipHtml.utf8().c_str()); |
3117 } | 3114 } |
3118 | 3115 |
3119 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) { | 3116 TEST_P(WebViewTest, SmartClipDoesNotCrashPositionReversed) { |
3120 WebString clipText; | 3117 WebString clipText; |
3121 WebString clipHtml; | 3118 WebString clipHtml; |
3122 WebRect clipRect; | |
3123 registerMockedHttpURLLoad("Ahem.ttf"); | 3119 registerMockedHttpURLLoad("Ahem.ttf"); |
3124 registerMockedHttpURLLoad("smartclip_reversed_positions.html"); | 3120 registerMockedHttpURLLoad("smartclip_reversed_positions.html"); |
3125 WebView* webView = m_webViewHelper.initializeAndLoad( | 3121 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( |
3126 m_baseURL + "smartclip_reversed_positions.html"); | 3122 m_baseURL + "smartclip_reversed_positions.html"); |
3127 webView->resize(WebSize(500, 500)); | 3123 webView->resize(WebSize(500, 500)); |
3128 webView->updateAllLifecyclePhases(); | 3124 webView->updateAllLifecyclePhases(); |
3129 // Left upper corner of the rect will be end position in the DOM hierarchy. | 3125 // Left upper corner of the rect will be end position in the DOM hierarchy. |
3130 WebRect cropRect(30, 110, 400, 250); | 3126 WebRect cropRect(30, 110, 400, 250); |
3131 // This should not still crash. See crbug.com/589082 for more details. | 3127 // This should not still crash. See crbug.com/589082 for more details. |
3132 webView->extractSmartClipData(cropRect, clipText, clipHtml, clipRect); | 3128 webView->mainFrameImpl()->extractSmartClipData(cropRect, clipText, clipHtml); |
3133 } | 3129 } |
3134 | 3130 |
3135 class CreateChildCounterFrameClient | 3131 class CreateChildCounterFrameClient |
3136 : public FrameTestHelpers::TestWebFrameClient { | 3132 : public FrameTestHelpers::TestWebFrameClient { |
3137 public: | 3133 public: |
3138 CreateChildCounterFrameClient() : m_count(0) {} | 3134 CreateChildCounterFrameClient() : m_count(0) {} |
3139 WebLocalFrame* createChildFrame(WebLocalFrame* parent, | 3135 WebLocalFrame* createChildFrame(WebLocalFrame* parent, |
3140 WebTreeScopeType, | 3136 WebTreeScopeType, |
3141 const WebString& name, | 3137 const WebString& name, |
3142 const WebString& uniqueName, | 3138 const WebString& uniqueName, |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4212 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); | 4208 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); |
4213 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); | 4209 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); |
4214 | 4210 |
4215 webView->resize(WebSize(800, 600)); | 4211 webView->resize(WebSize(800, 600)); |
4216 frame->printEnd(); | 4212 frame->printEnd(); |
4217 | 4213 |
4218 EXPECT_EQ(800, vwElement->offsetWidth()); | 4214 EXPECT_EQ(800, vwElement->offsetWidth()); |
4219 } | 4215 } |
4220 | 4216 |
4221 } // namespace blink | 4217 } // namespace blink |
OLD | NEW |