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

Unified Diff: services/shape_detection/text_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/text_detection_impl_mac_unittest.mm
diff --git a/services/shape_detection/text_detection_impl_mac_unittest.mm b/services/shape_detection/text_detection_impl_mac_unittest.mm
index f316d8e8eea465cc567b6d0481c65d4815dcb704..71def0f42eb62929225223ebe492cbce4ad050a3 100644
--- a/services/shape_detection/text_detection_impl_mac_unittest.mm
+++ b/services/shape_detection/text_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 {
@@ -82,29 +83,15 @@ TEST_F(TextDetectionImplMacTest, ScanOnce) {
EXPECT_EQ(static_cast<size_t>(width), CGImageGetWidth(cg_image));
EXPECT_EQ(static_cast<size_t>(height), CGImageGetHeight(cg_image));
- base::ScopedCFTypeRef<CFDataRef> raw_cg_image_data(
- CGDataProviderCopyData(CGImageGetDataProvider(cg_image)));
- EXPECT_TRUE(CFDataGetBytePtr(raw_cg_image_data));
- const int num_bytes = width * height * 4;
- EXPECT_EQ(num_bytes, CFDataGetLength(raw_cg_image_data));
-
- // Generate a new ScopedSharedBufferHandle of the aproppriate size, map it and
- // copy the generated text image pixels into it.
- auto 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 to Detect() and expect the response in callback.
EXPECT_CALL(*this, Detection(1)).WillOnce(RunClosure(quit_closure));
- impl_.Detect(std::move(handle), width, height,
- base::Bind(&TextDetectionImplMacTest::DetectCallback,
- base::Unretained(this)));
+ impl_.Detect(bitmap, base::Bind(&TextDetectionImplMacTest::DetectCallback,
+ base::Unretained(this)));
run_loop.Run();
}

Powered by Google App Engine
This is Rietveld 408576698