Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/command_line.h" | |
| 6 #include "content/public/common/content_switches.h" | |
| 7 #include "content/public/test/browser_test_utils.h" | |
| 8 #include "content/public/test/content_browser_test.h" | |
| 9 #include "content/public/test/content_browser_test_utils.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 const char faceDetectionTestHtml[] = "/media/face_detection_test.html"; | |
|
Reilly Grant (use Gerrit)
2016/10/18 00:28:14
kFaceDetectionTestHtml
| |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 // This class contains content_browsertests for Shape Detection API, which | |
| 20 // allows for generating bounding boxes of face for a still image. | |
| 21 class ShapeDetectionBrowserTest : public ContentBrowserTest { | |
| 22 public: | |
| 23 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 24 // Specific flag to enable ShapeDetection and DOMRect API. | |
| 25 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 26 switches::kEnableBlinkFeatures, "ShapeDetection, GeometryInterfaces"); | |
| 27 } | |
| 28 | |
| 29 protected: | |
| 30 void RunDetectFacesOnImageUrl(const std::string image_path, | |
| 31 const std::string expected_results) { | |
| 32 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 33 | |
| 34 GURL html_url(embedded_test_server()->GetURL(faceDetectionTestHtml)); | |
| 35 GURL image_url(embedded_test_server()->GetURL(image_path)); | |
| 36 NavigateToURL(shell(), html_url); | |
| 37 std::string js_command = | |
| 38 "detectFacesOnImageUrl('" + image_url.spec() + "')"; | |
| 39 std::string results; | |
| 40 ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), js_command, &results)); | |
| 41 ASSERT_EQ(expected_results, results); | |
| 42 } | |
| 43 }; | |
| 44 | |
| 45 IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, | |
| 46 DetectFacesOnImageWithNoFaces) { | |
| 47 const std::string image_path = "/blank.jpg"; | |
| 48 RunDetectFacesOnImageUrl(image_path, ""); | |
| 49 } | |
| 50 | |
| 51 IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, | |
| 52 DetectFacesOnImageWithOneFace) { | |
| 53 const std::string image_path = "/single_face.jpg"; | |
| 54 RunDetectFacesOnImageUrl(image_path, "x=84.53125,y=91.03125,w=130,h=130#"); | |
| 55 } | |
| 56 | |
| 57 } // namespace content | |
| OLD | NEW |