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

Unified Diff: services/shape_detection/barcode_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, 7 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 side-by-side diff with in-line comments
Download patch
Index: services/shape_detection/barcode_detection_impl_mac_unittest.mm
diff --git a/services/shape_detection/barcode_detection_impl_mac_unittest.mm b/services/shape_detection/barcode_detection_impl_mac_unittest.mm
index 3184083ccd5dbae26932c2157e9cf9a14944eaed..b30879c511f9a1731b1aeff284ea703725d7b8fe 100644
--- a/services/shape_detection/barcode_detection_impl_mac_unittest.mm
+++ b/services/shape_detection/barcode_detection_impl_mac_unittest.mm
@@ -13,6 +13,7 @@
#include "base/run_loop.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/utils/mac/SkCGUtils.h"
#include "ui/gl/gl_switches.h"
namespace shape_detection {
@@ -65,7 +66,6 @@ TEST_F(BarcodeDetectionImplMacTest, ScanOneBarcode) {
const gfx::Size size([qr_code_image extent].size.width,
[qr_code_image extent].size.height);
- const int num_bytes = size.GetArea() * 4 /* bytes per pixel */;
base::scoped_nsobject<CIContext> context([[CIContext alloc] init]);
@@ -74,30 +74,16 @@ TEST_F(BarcodeDetectionImplMacTest, ScanOneBarcode) {
EXPECT_EQ(static_cast<size_t>(size.width()), CGImageGetWidth(cg_image));
EXPECT_EQ(static_cast<size_t>(size.height()), CGImageGetHeight(cg_image));
- base::ScopedCFTypeRef<CFDataRef> raw_cg_image_data(
- CGDataProviderCopyData(CGImageGetDataProvider(cg_image)));
- EXPECT_TRUE(CFDataGetBytePtr(raw_cg_image_data));
- EXPECT_EQ(num_bytes, CFDataGetLength(raw_cg_image_data));
-
- // Generate a new ScopedSharedBufferHandle of the aproppriate size, map it and
- // copy the generated qr code image pixels into it.
- mojo::ScopedSharedBufferHandle handle =
- mojo::SharedBufferHandle::Create(num_bytes);
- ASSERT_TRUE(handle->is_valid());
-
- mojo::ScopedSharedBufferMapping mapping = handle->Map(num_bytes);
- ASSERT_TRUE(mapping);
-
- memcpy(mapping.get(), CFDataGetBytePtr(raw_cg_image_data), num_bytes);
+ SkBitmap bitmap;
+ ASSERT_TRUE(SkCreateBitmapFromCGImage(&bitmap, cg_image));
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
// Send the image Detect() and expect the response in callback.
EXPECT_CALL(*this, Detection(1, kInfoString))
.WillOnce(RunClosure(quit_closure));
- impl_.Detect(std::move(handle), size.width(), size.height(),
- base::Bind(&BarcodeDetectionImplMacTest::DetectCallback,
- base::Unretained(this)));
+ impl_.Detect(bitmap, base::Bind(&BarcodeDetectionImplMacTest::DetectCallback,
+ base::Unretained(this)));
run_loop.Run();
}
« no previous file with comments | « services/shape_detection/barcode_detection_impl_mac.mm ('k') | services/shape_detection/detection_utils_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698