• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "mojo/public/cpp/base/memory_allocator_dump_cross_process_uid_mojom_traits.h"
6 #include "mojo/public/cpp/test_support/test_utils.h"
7 #include "mojo/public/mojom/base/memory_allocator_dump_cross_process_uid.mojom.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 
10 namespace mojo_base {
11 namespace memory_allocator_dump_cross_process_uid_unittest {
12 
TEST(MemoryAllocatorDumpCrossProcessUidTest,SerializeFailsOnZeroValue)13 TEST(MemoryAllocatorDumpCrossProcessUidTest, SerializeFailsOnZeroValue) {
14   base::trace_event::MemoryAllocatorDumpGuid in(0);
15   base::trace_event::MemoryAllocatorDumpGuid out;
16 
17   ASSERT_FALSE(mojo::test::SerializeAndDeserialize<
18                mojom::MemoryAllocatorDumpCrossProcessUid>(&in, &out));
19   EXPECT_EQ(in, out);
20 }
21 
TEST(MemoryAllocatorDumpCrossProcessUidTest,SerializeSucceedsOnValidIntValue)22 TEST(MemoryAllocatorDumpCrossProcessUidTest, SerializeSucceedsOnValidIntValue) {
23   base::trace_event::MemoryAllocatorDumpGuid in(12345);
24   base::trace_event::MemoryAllocatorDumpGuid out;
25 
26   ASSERT_TRUE(mojo::test::SerializeAndDeserialize<
27               mojom::MemoryAllocatorDumpCrossProcessUid>(&in, &out));
28   EXPECT_EQ(in, out);
29 }
30 
TEST(MemoryAllocatorDumpCrossProcessUidTest,SerializeSucceedsOnValidStringValue)31 TEST(MemoryAllocatorDumpCrossProcessUidTest,
32      SerializeSucceedsOnValidStringValue) {
33   base::trace_event::MemoryAllocatorDumpGuid in("12345");
34   base::trace_event::MemoryAllocatorDumpGuid out;
35 
36   ASSERT_TRUE(mojo::test::SerializeAndDeserialize<
37               mojom::MemoryAllocatorDumpCrossProcessUid>(&in, &out));
38   EXPECT_EQ(in, out);
39 }
40 
41 }  // namespace memory_allocator_dump_cross_process_uid_unittest
42 }  // namespace mojo_base