summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/graphics/paint/display_item_client_test.cc
blob: 850ec26dee5f64ad9d7e2ae5f3ec0b95c2d2b177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2015 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 "third_party/blink/renderer/platform/graphics/paint/display_item_client.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/testing/fake_display_item_client.h"

namespace blink {
namespace {

#if DCHECK_IS_ON() && !defined(UNDEFINED_SANITIZER)

TEST(DisplayItemClientTest, IsAliveAndSafeDebugName) {
  const auto* invalid_client = reinterpret_cast<DisplayItemClient*>(0x12345678);
  EXPECT_FALSE(invalid_client->IsAlive());
  EXPECT_EQ("DEAD", invalid_client->SafeDebugName());

  FakeDisplayItemClient* test_client = new FakeDisplayItemClient;
  EXPECT_TRUE(test_client->IsAlive());
  EXPECT_EQ("Just created:FakeDisplayItemClient", test_client->SafeDebugName());
  test_client->Validate();
  EXPECT_EQ("FakeDisplayItemClient", test_client->SafeDebugName());

  delete test_client;
  EXPECT_FALSE(test_client->IsAlive());
  EXPECT_EQ("DEAD", test_client->SafeDebugName());
}

#endif

}  // namespace
}  // namespace blink