Skip to content

Commit

Permalink
Migrate all TraitsTestService interfaces to the new Mojo types
Browse files Browse the repository at this point in the history
Convert all users of the content_capture::mojom::TraitsTestService,
gfx::mojom::ImageTraitsTestService, gfx::mojom::RangeTraitsTestService,
gfx::mojom::TraitsTestService, gpu::mojom::TraitsTestService,
media::mojom::TraitsTestService, sandbox::mac::mojom::TraitsTestService,
skia::mojom::TraitsTestService, ui::mojom::IMEStructTraitsTest and
ui::mojom::TraitsTestService interfaces.

Bug: 955171
Change-Id: I8b324acc51cbd9647ee34beead76f1616ed3965b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841132
Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#705483}
  • Loading branch information
hferreiro authored and Commit Bot committed Oct 14, 2019
1 parent c00d5f7 commit 328780c
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "components/content_capture/common/traits_test_service.test-mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace content_capture {
Expand All @@ -18,10 +19,10 @@ class ContentCaptureStructTraitsTest : public testing::Test,
ContentCaptureStructTraitsTest() = default;

protected:
mojom::TraitsTestServicePtr GetTraitsTestProxy() {
mojom::TraitsTestServicePtr proxy;
traits_test_bindings_.AddBinding(this, mojo::MakeRequest(&proxy));
return proxy;
mojo::Remote<mojom::TraitsTestService> GetTraitsTestRemote() {
mojo::Remote<mojom::TraitsTestService> remote;
traits_test_receivers_.Add(this, remote.BindNewPipeAndPassReceiver());
return remote;
}

private:
Expand All @@ -33,7 +34,7 @@ class ContentCaptureStructTraitsTest : public testing::Test,
}

base::test::TaskEnvironment task_environment_;
mojo::BindingSet<TraitsTestService> traits_test_bindings_;
mojo::ReceiverSet<TraitsTestService> traits_test_receivers_;

DISALLOW_COPY_AND_ASSIGN(ContentCaptureStructTraitsTest);
};
Expand All @@ -49,9 +50,9 @@ TEST_F(ContentCaptureStructTraitsTest, ContentCaptureData) {
input.bounds = gfx::Rect(10, 10);
input.children.push_back(child);

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
ContentCaptureData output;
proxy->EchoContentCaptureData(input, &output);
remote->EchoContentCaptureData(input, &output);
EXPECT_EQ(input, output);
}

Expand Down
57 changes: 29 additions & 28 deletions gpu/ipc/common/mojom_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "gpu/ipc/common/gpu_feature_info.mojom.h"
#include "gpu/ipc/common/gpu_feature_info_mojom_traits.h"
#include "gpu/ipc/common/traits_test_service.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gpu {
Expand All @@ -23,10 +24,10 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
StructTraitsTest() = default;

protected:
mojom::TraitsTestServicePtr GetTraitsTestProxy() {
mojom::TraitsTestServicePtr proxy;
traits_test_bindings_.AddBinding(this, mojo::MakeRequest(&proxy));
return proxy;
mojo::Remote<mojom::TraitsTestService> GetTraitsTestRemote() {
mojo::Remote<mojom::TraitsTestService> remote;
traits_test_receivers_.Add(this, remote.BindNewPipeAndPassReceiver());
return remote;
}

private:
Expand Down Expand Up @@ -83,7 +84,7 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
}

base::test::TaskEnvironment task_environment_;
mojo::BindingSet<TraitsTestService> traits_test_bindings_;
mojo::ReceiverSet<TraitsTestService> traits_test_receivers_;

DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
};
Expand All @@ -93,9 +94,9 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
TEST_F(StructTraitsTest, DxDiagNode) {
gpu::DxDiagNode input;
input.values["abc"] = "123";
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::DxDiagNode output;
proxy->EchoDxDiagNode(input, &output);
remote->EchoDxDiagNode(input, &output);

gpu::DxDiagNode test_dx_diag_node;
test_dx_diag_node.values["abc"] = "123";
Expand Down Expand Up @@ -123,9 +124,9 @@ TEST_F(StructTraitsTest, GPUDevice) {
input.vendor_string = vendor_string;
input.device_string = device_string;
input.active = false;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::GPUInfo::GPUDevice output;
proxy->EchoGpuDevice(input, &output);
remote->EchoGpuDevice(input, &output);

EXPECT_EQ(vendor_id, output.vendor_id);
EXPECT_EQ(device_id, output.device_id);
Expand Down Expand Up @@ -225,9 +226,9 @@ TEST_F(StructTraitsTest, GpuInfo) {
input.rgba_visual = rgba_visual;
#endif

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::GPUInfo output;
proxy->EchoGpuInfo(input, &output);
remote->EchoGpuInfo(input, &output);

EXPECT_EQ(optimus, output.optimus);
EXPECT_EQ(amd_switchable, output.amd_switchable);
Expand Down Expand Up @@ -309,19 +310,19 @@ TEST_F(StructTraitsTest, GpuInfo) {

TEST_F(StructTraitsTest, EmptyGpuInfo) {
gpu::GPUInfo input;
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::GPUInfo output;
proxy->EchoGpuInfo(input, &output);
remote->EchoGpuInfo(input, &output);
}

TEST_F(StructTraitsTest, Mailbox) {
const int8_t mailbox_name[GL_MAILBOX_SIZE_CHROMIUM] = {
0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2};
gpu::Mailbox input;
input.SetName(mailbox_name);
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::Mailbox output;
proxy->EchoMailbox(input, &output);
remote->EchoMailbox(input, &output);
gpu::Mailbox test_mailbox;
test_mailbox.SetName(mailbox_name);
EXPECT_EQ(test_mailbox, output);
Expand All @@ -348,9 +349,9 @@ TEST_F(StructTraitsTest, MailboxHolder) {
input.sync_token = sync_token;
input.texture_target = texture_target;

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::MailboxHolder output;
proxy->EchoMailboxHolder(input, &output);
remote->EchoMailboxHolder(input, &output);
EXPECT_EQ(mailbox, output.mailbox);
EXPECT_EQ(sync_token, output.sync_token);
EXPECT_EQ(texture_target, output.texture_target);
Expand All @@ -363,9 +364,9 @@ TEST_F(StructTraitsTest, SyncToken) {
const uint64_t release_count = 0xdeadbeefdead;
gpu::SyncToken input(namespace_id, command_buffer_id, release_count);
input.SetVerifyFlush();
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::SyncToken output;
proxy->EchoSyncToken(input, &output);
remote->EchoSyncToken(input, &output);
EXPECT_EQ(namespace_id, output.namespace_id());
EXPECT_EQ(command_buffer_id, output.command_buffer_id());
EXPECT_EQ(release_count, output.release_count());
Expand All @@ -388,9 +389,9 @@ TEST_F(StructTraitsTest, VideoDecodeAcceleratorSupportedProfile) {
input.min_resolution = min_resolution;
input.encrypted_only = false;

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::VideoDecodeAcceleratorSupportedProfile output;
proxy->EchoVideoDecodeAcceleratorSupportedProfile(input, &output);
remote->EchoVideoDecodeAcceleratorSupportedProfile(input, &output);
EXPECT_EQ(profile, output.profile);
EXPECT_EQ(max_resolution, output.max_resolution);
EXPECT_EQ(min_resolution, output.min_resolution);
Expand All @@ -407,9 +408,9 @@ TEST_F(StructTraitsTest, VideoDecodeAcceleratorCapabilities) {
input.supported_profiles.push_back(
gpu::VideoDecodeAcceleratorSupportedProfile());

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::VideoDecodeAcceleratorCapabilities output;
proxy->EchoVideoDecodeAcceleratorCapabilities(input, &output);
remote->EchoVideoDecodeAcceleratorCapabilities(input, &output);
EXPECT_EQ(flags, output.flags);
EXPECT_EQ(input.supported_profiles.size(), output.supported_profiles.size());
}
Expand All @@ -428,9 +429,9 @@ TEST_F(StructTraitsTest, VideoEncodeAcceleratorSupportedProfile) {
input.max_framerate_numerator = max_framerate_numerator;
input.max_framerate_denominator = max_framerate_denominator;

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
gpu::VideoEncodeAcceleratorSupportedProfile output;
proxy->EchoVideoEncodeAcceleratorSupportedProfile(input, &output);
remote->EchoVideoEncodeAcceleratorSupportedProfile(input, &output);
EXPECT_EQ(profile, output.profile);
EXPECT_EQ(min_resolution, output.min_resolution);
EXPECT_EQ(max_resolution, output.max_resolution);
Expand All @@ -444,9 +445,9 @@ TEST_F(StructTraitsTest, GpuPreferences) {
prefs.disable_gpu_watchdog = true;
prefs.enable_gpu_driver_debug_logging = true;

mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
GpuPreferences echo;
proxy->EchoGpuPreferences(prefs, &echo);
remote->EchoGpuPreferences(prefs, &echo);
EXPECT_TRUE(echo.gpu_startup_dialog);
EXPECT_TRUE(echo.disable_gpu_watchdog);
EXPECT_TRUE(echo.enable_gpu_driver_debug_logging);
Expand Down
18 changes: 9 additions & 9 deletions media/mojo/mojom/video_frame_mojom_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "media/mojo/common/mojo_shared_buffer_video_frame.h"
#include "media/mojo/mojom/traits_test_service.mojom.h"
#include "media/video/fake_gpu_memory_buffer.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/buffer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/rect.h"
Expand All @@ -38,16 +38,16 @@ class VideoFrameStructTraitsTest : public testing::Test,
VideoFrameStructTraitsTest() = default;

protected:
media::mojom::TraitsTestServicePtr GetTraitsTestProxy() {
media::mojom::TraitsTestServicePtr proxy;
traits_test_bindings_.AddBinding(this, mojo::MakeRequest(&proxy));
return proxy;
mojo::Remote<mojom::TraitsTestService> GetTraitsTestRemote() {
mojo::Remote<mojom::TraitsTestService> remote;
traits_test_receivers_.Add(this, remote.BindNewPipeAndPassReceiver());
return remote;
}

bool RoundTrip(scoped_refptr<VideoFrame>* frame) {
scoped_refptr<VideoFrame> input = std::move(*frame);
media::mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
return proxy->EchoVideoFrame(std::move(input), frame);
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
return remote->EchoVideoFrame(std::move(input), frame);
}

private:
Expand All @@ -57,7 +57,7 @@ class VideoFrameStructTraitsTest : public testing::Test,
}

base::test::TaskEnvironment task_environment_;
mojo::BindingSet<TraitsTestService> traits_test_bindings_;
mojo::ReceiverSet<TraitsTestService> traits_test_receivers_;

DISALLOW_COPY_AND_ASSIGN(VideoFrameStructTraitsTest);
};
Expand Down
14 changes: 6 additions & 8 deletions sandbox/mac/mojom/mojom_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// found in the LICENSE file.

#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "sandbox/mac/mojom/seatbelt_extension_token_mojom_traits.h"
#include "sandbox/mac/mojom/traits_test_service.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -14,12 +15,9 @@ namespace {
class StructTraitsTest : public testing::Test,
public sandbox::mac::mojom::TraitsTestService {
public:
StructTraitsTest()
: interface_ptr_(), binding_(this, mojo::MakeRequest(&interface_ptr_)) {}
StructTraitsTest() : receiver_(this, remote_.BindNewPipeAndPassReceiver()) {}

sandbox::mac::mojom::TraitsTestService* interface() {
return interface_ptr_.get();
}
sandbox::mac::mojom::TraitsTestService* interface() { return remote_.get(); }

private:
// TraitsTestService:
Expand All @@ -31,8 +29,8 @@ class StructTraitsTest : public testing::Test,

base::test::TaskEnvironment task_environment_;

sandbox::mac::mojom::TraitsTestServicePtr interface_ptr_;
mojo::Binding<sandbox::mac::mojom::TraitsTestService> binding_;
mojo::Remote<sandbox::mac::mojom::TraitsTestService> remote_;
mojo::Receiver<sandbox::mac::mojom::TraitsTestService> receiver_;
};

TEST_F(StructTraitsTest, SeatbeltExtensionToken) {
Expand Down
31 changes: 16 additions & 15 deletions skia/public/mojom/test/mojom_traits_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// found in the LICENSE file.

#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "skia/public/mojom/test/traits_test_service.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColorFilter.h"
Expand All @@ -23,10 +24,10 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
StructTraitsTest() = default;

protected:
mojom::TraitsTestServicePtr GetTraitsTestProxy() {
mojom::TraitsTestServicePtr proxy;
traits_test_bindings_.AddBinding(this, mojo::MakeRequest(&proxy));
return proxy;
mojo::Remote<mojom::TraitsTestService> GetTraitsTestRemote() {
mojo::Remote<mojom::TraitsTestService> remote;
traits_test_receivers_.Add(this, remote.BindNewPipeAndPassReceiver());
return remote;
}

private:
Expand All @@ -47,7 +48,7 @@ class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
}

base::test::TaskEnvironment task_environment_;
mojo::BindingSet<TraitsTestService> traits_test_bindings_;
mojo::ReceiverSet<TraitsTestService> traits_test_receivers_;

DISALLOW_COPY_AND_ASSIGN(StructTraitsTest);
};
Expand All @@ -59,15 +60,15 @@ TEST_F(StructTraitsTest, ImageInfo) {
34, 56, SkColorType::kGray_8_SkColorType,
SkAlphaType::kUnpremul_SkAlphaType,
SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kAdobeRGB));
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
SkImageInfo output;
proxy->EchoImageInfo(input, &output);
remote->EchoImageInfo(input, &output);
EXPECT_EQ(input, output);

SkImageInfo another_input_with_null_color_space =
SkImageInfo::Make(54, 43, SkColorType::kRGBA_8888_SkColorType,
SkAlphaType::kPremul_SkAlphaType, nullptr);
proxy->EchoImageInfo(another_input_with_null_color_space, &output);
remote->EchoImageInfo(another_input_with_null_color_space, &output);
EXPECT_FALSE(output.colorSpace());
EXPECT_EQ(another_input_with_null_color_space, output);
}
Expand All @@ -80,9 +81,9 @@ TEST_F(StructTraitsTest, Bitmap) {
SkNamedGamut::kRec2020)));
input.eraseColor(SK_ColorYELLOW);
input.erase(SK_ColorTRANSPARENT, SkIRect::MakeXYWH(0, 1, 2, 3));
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
SkBitmap output;
proxy->EchoBitmap(input, &output);
remote->EchoBitmap(input, &output);
EXPECT_EQ(input.info(), output.info());
EXPECT_EQ(input.rowBytes(), output.rowBytes());
EXPECT_TRUE(gfx::BitmapsAreEqual(input, output));
Expand All @@ -99,19 +100,19 @@ TEST_F(StructTraitsTest, BitmapWithExtraRowBytes) {
input.allocPixels(info, info.minRowBytes() + extra);
input.eraseColor(SK_ColorRED);
input.erase(SK_ColorTRANSPARENT, SkIRect::MakeXYWH(0, 1, 2, 3));
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
SkBitmap output;
proxy->EchoBitmap(input, &output);
remote->EchoBitmap(input, &output);
EXPECT_EQ(input.info(), output.info());
EXPECT_EQ(input.rowBytes(), output.rowBytes());
EXPECT_TRUE(gfx::BitmapsAreEqual(input, output));
}

TEST_F(StructTraitsTest, BlurImageFilterTileMode) {
SkBlurImageFilter::TileMode input(SkBlurImageFilter::kClamp_TileMode);
mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote();
SkBlurImageFilter::TileMode output;
proxy->EchoBlurImageFilterTileMode(input, &output);
remote->EchoBlurImageFilterTileMode(input, &output);
EXPECT_EQ(input, output);
}

Expand Down
Loading

0 comments on commit 328780c

Please sign in to comment.