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

Unified Diff: Source/web/tests/WebViewTest.cpp

Issue 464613003: WebView unit tests for Defect 248426 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebViewTest.cpp
diff --git a/Source/web/tests/WebViewTest.cpp b/Source/web/tests/WebViewTest.cpp
index 502c90288406941958972a9872270334c6d5ce22..bf92cf0cddb5de4c903dc53ed9485f43191886a6 100644
--- a/Source/web/tests/WebViewTest.cpp
+++ b/Source/web/tests/WebViewTest.cpp
@@ -66,6 +66,7 @@
#include "public/web/WebFrameClient.h"
#include "public/web/WebHitTestResult.h"
#include "public/web/WebInputEvent.h"
+#include "public/web/WebScriptSource.h"
#include "public/web/WebSettings.h"
#include "public/web/WebViewClient.h"
#include "public/web/WebWidget.h"
@@ -2137,4 +2138,28 @@ TEST_F(WebViewTest, FirstUserGestureObservedGestureTap)
webView->setAutofillClient(0);
}
+TEST_F(WebViewTest, OnTTSUtteranceForNoSelection)
jamesr 2014/08/12 23:34:15 this test doesn't have anything to do with TTS. it
+{
+ // Note: This is a test to somewhat simulate a CL submitted for
+ // crbug.com/248426. Follow https://codereview.chromium.org/342143004/.
+ // As of now there is no good way to test a TTS session. Since the patch
+ // uses contentAsText() to fetch fully rendered text from a web content
+ // it is okay to check if text returned from SelectAll is same as
+ // contentAsText().
jamesr 2014/08/12 23:34:15 none of this comment has anything to do with what
+ // TODO(a.sarkar.arun@gmail.com): When Chromium has a better support for
+ // testing TTS extensively, this test should be improved and moved to a
+ // more appropriate place.
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("longpress_selection.html"));
+ WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_selection.html", true);
+ WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
+ frame->executeScript(WebScriptSource(WebString::fromUTF8("document.execCommand('SelectAll', false, null)")));
+
+ std::string output1 = frame->selectionAsText().utf8();
jamesr 2014/08/12 23:34:15 output1 isn't a very useful variable name. what do
+
+ const int kMaxOutputCharacters = 1024;
+ std::string output = frame->contentAsText(kMaxOutputCharacters).utf8();
+ EXPECT_EQ(output1, output);
+
+}
+
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698