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

Unified Diff: cc/ipc/struct_traits_unittest.cc

Issue 2023973002: Introduce cc StructTraits unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ken's comment Created 4 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: cc/ipc/struct_traits_unittest.cc
diff --git a/cc/ipc/struct_traits_unittest.cc b/cc/ipc/struct_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8243c4b1d3450d2ab6451a4537651356be586e82
--- /dev/null
+++ b/cc/ipc/struct_traits_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "cc/ipc/traits_test_service.mojom.h"
+#include "cc/quads/render_pass_id.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+
+namespace {
+
+class StructTraitsTest : public testing::Test, public mojom::TraitsTestService {
+ public:
+ StructTraitsTest() {}
+
+ protected:
+ mojom::TraitsTestServicePtr GetTraitsTestProxy() {
+ return traits_test_bindings_.CreateInterfacePtrAndBind(this);
+ }
+
+ private:
+ // TraitsTestService:
+ void EchoRenderPassId(const RenderPassId& r,
+ const EchoRenderPassIdCallback& callback) override {
+ callback.Run(r);
+ }
+
+ void EchoSurfaceId(const SurfaceId& s,
+ const EchoSurfaceIdCallback& callback) override {
+ callback.Run(s);
+ }
+
+ mojo::BindingSet<TraitsTestService> traits_test_bindings_;
+};
+
+} // namespace
+
+TEST_F(StructTraitsTest, RenderPassId) {
+ const int layer_id = 1337;
+ const uint32_t index = 0xdeadbeef;
+ RenderPassId input(layer_id, index);
+ base::RunLoop loop;
+ mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
+ proxy->EchoRenderPassId(input, [&](const RenderPassId& pass) {
Tom Sepez 2016/05/31 16:07:43 I'd expect we'd capture layer_id and index by valu
Fady Samuel 2016/05/31 16:37:09 I'm passing all of input by value now. WDYT?
+ EXPECT_EQ(input.layer_id, pass.layer_id);
+ EXPECT_EQ(input.index, pass.index);
+ loop.Quit();
+ });
+ loop.Run();
+}
+
+TEST_F(StructTraitsTest, SurfaceId) {
+ const uint32_t id_namespace = 1337;
+ const uint32_t local_id = 0xfbadbeef;
+ const uint64_t nonce = 0xdeadbeef;
+ SurfaceId input(id_namespace, local_id, nonce);
+ base::RunLoop loop;
+ mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy();
+ proxy->EchoSurfaceId(input, [&](const SurfaceId& pass) {
+ EXPECT_EQ(input.id_namespace(), pass.id_namespace());
Tom Sepez 2016/05/31 16:07:42 same here.
Fady Samuel 2016/05/31 16:37:09 Passing input by value.
+ EXPECT_EQ(input.local_id(), pass.local_id());
+ EXPECT_EQ(input.nonce(), pass.nonce());
+ loop.Quit();
+ });
+ loop.Run();
+}
+
+} // namespace cc
« cc/cc_tests.gyp ('K') | « cc/ipc/DEPS ('k') | cc/ipc/traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698