Chromium Code Reviews| Index: content/browser/shapedetection/shapedetection_browsertest.cc |
| diff --git a/content/browser/shapedetection/shapedetection_browsertest.cc b/content/browser/shapedetection/shapedetection_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1ef347d682edadd1241d347cd1a777ffe3f3a960 |
| --- /dev/null |
| +++ b/content/browser/shapedetection/shapedetection_browsertest.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "content/public/test/browser_test_utils.h" |
| +#include "content/public/test/content_browser_test.h" |
| +#include "content/public/test/content_browser_test_utils.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| + |
| +const char faceDetectionTestHtml[] = "/media/face_detection_test.html"; |
|
Reilly Grant (use Gerrit)
2016/10/18 00:28:14
kFaceDetectionTestHtml
|
| + |
| +} // namespace |
| + |
| +// This class contains content_browsertests for Shape Detection API, which |
| +// allows for generating bounding boxes of face for a still image. |
| +class ShapeDetectionBrowserTest : public ContentBrowserTest { |
| + public: |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + // Specific flag to enable ShapeDetection and DOMRect API. |
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| + switches::kEnableBlinkFeatures, "ShapeDetection, GeometryInterfaces"); |
| + } |
| + |
| + protected: |
| + void RunDetectFacesOnImageUrl(const std::string image_path, |
| + const std::string expected_results) { |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + |
| + GURL html_url(embedded_test_server()->GetURL(faceDetectionTestHtml)); |
| + GURL image_url(embedded_test_server()->GetURL(image_path)); |
| + NavigateToURL(shell(), html_url); |
| + std::string js_command = |
| + "detectFacesOnImageUrl('" + image_url.spec() + "')"; |
| + std::string results; |
| + ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), js_command, &results)); |
| + ASSERT_EQ(expected_results, results); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, |
| + DetectFacesOnImageWithNoFaces) { |
| + const std::string image_path = "/blank.jpg"; |
| + RunDetectFacesOnImageUrl(image_path, ""); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, |
| + DetectFacesOnImageWithOneFace) { |
| + const std::string image_path = "/single_face.jpg"; |
| + RunDetectFacesOnImageUrl(image_path, "x=84.53125,y=91.03125,w=130,h=130#"); |
| +} |
| + |
| +} // namespace content |