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

Side by Side Diff: services/shape_detection/face_detection_impl_mac_unittest.mm

Issue 2755393002: Revert of RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/shape_detection/face_detection_impl_mac.h" 5 #include "services/shape_detection/face_detection_impl_mac.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 reinterpret_cast<const uint8_t*>(image_as_jpeg.data()), 69 reinterpret_cast<const uint8_t*>(image_as_jpeg.data()),
70 image_as_jpeg.size()); 70 image_as_jpeg.size());
71 ASSERT_TRUE(image); 71 ASSERT_TRUE(image);
72 ASSERT_EQ(kJpegImageWidth, image->width()); 72 ASSERT_EQ(kJpegImageWidth, image->width());
73 ASSERT_EQ(kJpegImageHeight, image->height()); 73 ASSERT_EQ(kJpegImageHeight, image->height());
74 74
75 const gfx::Size size(image->width(), image->height()); 75 const gfx::Size size(image->width(), image->height());
76 const int num_bytes = size.GetArea() * 4 /* bytes per pixel */; 76 const int num_bytes = size.GetArea() * 4 /* bytes per pixel */;
77 ASSERT_EQ(num_bytes, image->computeSize64()); 77 ASSERT_EQ(num_bytes, image->computeSize64());
78 78
79 // Generate a new ScopedSharedBufferHandle of the aproppriate size, map it and
80 // copy the image pixels into it.
81 mojo::ScopedSharedBufferHandle handle =
82 mojo::SharedBufferHandle::Create(num_bytes);
83 ASSERT_TRUE(handle->is_valid());
84
85 mojo::ScopedSharedBufferMapping mapping = handle->Map(num_bytes);
86 ASSERT_TRUE(mapping);
87
88 memcpy(mapping.get(), image->getPixels(), num_bytes);
89
79 base::RunLoop run_loop; 90 base::RunLoop run_loop;
80 base::Closure quit_closure = run_loop.QuitClosure(); 91 base::Closure quit_closure = run_loop.QuitClosure();
81 // Send the image to Detect() and expect the response in callback. 92 // Send the image to Detect() and expect the response in callback.
82 EXPECT_CALL(*this, Detection(1)).WillOnce(RunClosure(quit_closure)); 93 EXPECT_CALL(*this, Detection(1)).WillOnce(RunClosure(quit_closure));
83 impl_->Detect(*image, base::Bind(&FaceDetectionImplMacTest::DetectCallback, 94 impl_->Detect(std::move(handle), size.width(), size.height(),
84 base::Unretained(this))); 95 base::Bind(&FaceDetectionImplMacTest::DetectCallback,
96 base::Unretained(this)));
85 97
86 run_loop.Run(); 98 run_loop.Run();
87 } 99 }
88 100
89 INSTANTIATE_TEST_CASE_P(, FaceDetectionImplMacTest, ValuesIn({true, false})); 101 INSTANTIATE_TEST_CASE_P(, FaceDetectionImplMacTest, ValuesIn({true, false}));
90 102
91 } // shape_detection namespace 103 } // shape_detection namespace
OLDNEW
« no previous file with comments | « services/shape_detection/face_detection_impl_mac.mm ('k') | services/shape_detection/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698