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

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

Issue 2875243002: RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: RELAND2: ShapeDetection: use mojom::Bitmap for mojo interface. Created 3 years, 6 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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 reinterpret_cast<const uint8_t*>(image_as_jpeg.data()), 75 reinterpret_cast<const uint8_t*>(image_as_jpeg.data()),
76 image_as_jpeg.size()); 76 image_as_jpeg.size());
77 ASSERT_TRUE(image); 77 ASSERT_TRUE(image);
78 ASSERT_EQ(kJpegImageWidth, image->width()); 78 ASSERT_EQ(kJpegImageWidth, image->width());
79 ASSERT_EQ(kJpegImageHeight, image->height()); 79 ASSERT_EQ(kJpegImageHeight, image->height());
80 80
81 const gfx::Size size(image->width(), image->height()); 81 const gfx::Size size(image->width(), image->height());
82 const int num_bytes = size.GetArea() * 4 /* bytes per pixel */; 82 const int num_bytes = size.GetArea() * 4 /* bytes per pixel */;
83 ASSERT_EQ(num_bytes, image->computeSize64()); 83 ASSERT_EQ(num_bytes, image->computeSize64());
84 84
85 // Generate a new ScopedSharedBufferHandle of the aproppriate size, map it and
86 // copy the image pixels into it.
87 mojo::ScopedSharedBufferHandle handle =
88 mojo::SharedBufferHandle::Create(num_bytes);
89 ASSERT_TRUE(handle->is_valid());
90
91 mojo::ScopedSharedBufferMapping mapping = handle->Map(num_bytes);
92 ASSERT_TRUE(mapping);
93
94 memcpy(mapping.get(), image->getPixels(), num_bytes);
95
96 base::RunLoop run_loop; 85 base::RunLoop run_loop;
97 base::Closure quit_closure = run_loop.QuitClosure(); 86 base::Closure quit_closure = run_loop.QuitClosure();
98 // Send the image to Detect() and expect the response in callback. 87 // Send the image to Detect() and expect the response in callback.
99 EXPECT_CALL(*this, Detection()).WillOnce(RunClosure(quit_closure)); 88 EXPECT_CALL(*this, Detection()).WillOnce(RunClosure(quit_closure));
100 impl_->Detect(std::move(handle), size.width(), size.height(), 89 impl_->Detect(*image, base::Bind(&FaceDetectionImplMacTest::DetectCallback,
101 base::Bind(&FaceDetectionImplMacTest::DetectCallback, 90 base::Unretained(this)));
102 base::Unretained(this)));
103 91
104 run_loop.Run(); 92 run_loop.Run();
105 } 93 }
106 94
107 INSTANTIATE_TEST_CASE_P(, FaceDetectionImplMacTest, ValuesIn({true, false})); 95 INSTANTIATE_TEST_CASE_P(, FaceDetectionImplMacTest, ValuesIn({true, false}));
108 96
109 } // shape_detection namespace 97 } // 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