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 kFaceDetectionTestHtml[] = "/media/face_detection_test.html"; | |
| 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. | |
|
mcasas
2016/10/18 23:15:13
... for generating bounding boxes for faces on sti
xianglu
2016/10/19 23:26:10
Done.
| |
| 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) { | |
|
mcasas
2016/10/18 23:15:13
const std::string& (both parameters).
xianglu
2016/10/19 23:26:10
Done.
| |
| 32 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 33 | |
| 34 GURL html_url(embedded_test_server()->GetURL(kFaceDetectionTestHtml)); | |
| 35 GURL image_url(embedded_test_server()->GetURL(image_path)); | |
| 36 NavigateToURL(shell(), html_url); | |
| 37 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.
| |
| 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 #if defined(OS_ANDROID) | |
| 46 #define MAYBE_DetectFacesOnImageWithNoFaces DetectFacesOnImageWithNoFaces | |
| 47 #else | |
| 48 #define MAYBE_DetectFacesOnImageWithNoFaces DISABLED_DetectFacesOnImageWithNoFac es | |
| 49 #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.
| |
| 50 IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, | |
| 51 MAYBE_DetectFacesOnImageWithNoFaces) { | |
| 52 const std::string image_path = "/blank.jpg"; | |
| 53 RunDetectFacesOnImageUrl(image_path, ""); | |
| 54 } | |
| 55 | |
| 56 #if defined(OS_ANDROID) | |
| 57 #define MAYBE_DetectFacesOnImageWithOneFace DetectFacesOnImageWithOneFace | |
| 58 #else | |
| 59 #define MAYBE_DetectFacesOnImageWithOneFace DISABLED_DetectFacesOnImageWithOneFa ce | |
| 60 #endif | |
| 61 IN_PROC_BROWSER_TEST_F(ShapeDetectionBrowserTest, | |
| 62 MAYBE_DetectFacesOnImageWithOneFace) { | |
| 63 const std::string image_path = "/single_face.jpg"; | |
| 64 RunDetectFacesOnImageUrl(image_path, | |
| 65 "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.
| |
| 66 } | |
| 67 | |
| 68 } // namespace content | |
| OLD | NEW |