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..14ab374a8c3794460397e1e7789fb36cb31ae45b |
| --- /dev/null |
| +++ b/content/browser/shapedetection/shapedetection_browsertest.cc |
| @@ -0,0 +1,68 @@ |
| +// 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 kFaceDetectionTestHtml[] = "/media/face_detection_test.html"; |
| + |
| +} // namespace |
| + |
| +// This class contains content_browsertests for Shape Detection API, which |
| +// allows for generating bounding boxes of face for a still image. |
|
mcasas
2016/10/18 23:15:13
... for generating bounding boxes for faces on sti
xianglu
2016/10/19 23:26:10
Done.
|
| +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) { |
|
mcasas
2016/10/18 23:15:13
const std::string& (both parameters).
xianglu
2016/10/19 23:26:10
Done.
|
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + |
| + GURL html_url(embedded_test_server()->GetURL(kFaceDetectionTestHtml)); |
| + GURL image_url(embedded_test_server()->GetURL(image_path)); |
| + NavigateToURL(shell(), html_url); |
| + std::string js_command = |
|
mcasas
2016/10/18 23:15:13
const, here and in l. 34, 35 and 37.
xianglu
2016/10/19 23:26:10
Done.
|
| + "detectFacesOnImageUrl('" + image_url.spec() + "')"; |
| + std::string results; |
| + ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), js_command, &results)); |
| + ASSERT_EQ(expected_results, results); |
| + } |
| +}; |
| + |
| +#if defined(OS_ANDROID) |
| +#define MAYBE_DetectFacesOnImageWithNoFaces DetectFacesOnImageWithNoFaces |
| +#else |
| +#define MAYBE_DetectFacesOnImageWithNoFaces DISABLED_DetectFacesOnImageWithNoFaces |
| +#endif |
|
mcasas
2016/10/18 23:15:13
Bundle these l.45-49 and l.56-60 around l.10
and a
xianglu
2016/10/19 23:26:10
Done.
|
| +IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, |
| + MAYBE_DetectFacesOnImageWithNoFaces) { |
| + const std::string image_path = "/blank.jpg"; |
| + RunDetectFacesOnImageUrl(image_path, ""); |
| +} |
| + |
| +#if defined(OS_ANDROID) |
| +#define MAYBE_DetectFacesOnImageWithOneFace DetectFacesOnImageWithOneFace |
| +#else |
| +#define MAYBE_DetectFacesOnImageWithOneFace DISABLED_DetectFacesOnImageWithOneFace |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, |
| + MAYBE_DetectFacesOnImageWithOneFace) { |
| + const std::string image_path = "/single_face.jpg"; |
| + RunDetectFacesOnImageUrl(image_path, |
| + "x=68.640625,y=102.96875,w=171.5625,h=171.5625#"); |
|
mcasas
2016/10/18 23:15:13
Hmm I wonder if this would not produce failures du
xianglu
2016/10/19 23:26:10
Done.
|
| +} |
| + |
| +} // namespace content |