chromium/components/viz/service/debugger/viz_debugger_unittests/viz_debugger_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stddef.h>

#include <cstdio>
#include <unordered_map>
#include <utility>
#include <vector>

#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "components/viz/service/debugger/viz_debugger.h"
#include "components/viz/service/debugger/viz_debugger_unittests/viz_debugger_internal.h"
#include "components/viz/service/debugger/viz_debugger_unittests/viz_debugger_unittest_base.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/skia/include/core/SkAlphaType.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/vector2d_f.h"

#if VIZ_DEBUGGER_IS_ON()
_;
Mock;

namespace viz {

namespace {

static_assert;

class VisualDebuggerTest : public VisualDebuggerTestBase {};

TEST_F(VisualDebuggerTest, GeneralDrawSubmission) {}

static void FunctionNameTest(const char* anno_rect, gfx::RectF rect) {}

TEST_F(VisualDebuggerTest, FilterDrawSubmission) {}

constexpr const char kTestFlagFunctionAnnoName[] =;

DBG_FLAG_FBOOL(kTestFlagFunctionAnnoName, check_flag_enabled)

static bool FlagFunctionTestEnable() {}

TEST_F(VisualDebuggerTest, TestDebugFlagAnnoAndFunction) {}

// This tests makes sure that expensive string logging has no cost unless it is
// actively being filtered.
TEST_F(VisualDebuggerTest, NonFilterActiveNoCost) {}

// This tests passing a single buffer synchronously into the visual debuggeer
TEST_F(VisualDebuggerTest, SingleBufferSync) {}

// This tests passing multiple buffers into the visual debugger synchronously
TEST_F(VisualDebuggerTest, MultipleBuffersSync) {}

// This tests passing a single buffer into the visual debugger asynchronously
TEST_F(VisualDebuggerTest, SingleBufferAsync) {}

// This tests passing multiple buffers into the visual debugger asynchronously
TEST_F(VisualDebuggerTest, MultipleBuffersAsync) {}
}  // namespace
}  // namespace viz
#else  // VIZ_DEBUGGER_IS_ON()

class VisualDebuggerTest : public testing::Test {};

DBG_FLAG_FBOOL("unit.test.fake.anno", flag_default_value_check)

TEST_F(VisualDebuggerTest, TestDebugFlagAnnoAndFunction) {
  // Visual debugger is disabled at build level this check should always return
  // false.
  EXPECT_FALSE(viz::VizDebugger::GetInstance()->IsEnabled());
  // The default value for a bool flag when the visual debugger is disabled is
  // false.
  EXPECT_FALSE(flag_default_value_check());
}

// This tests makes sure that expressions inside debugging macros are not
// evaluated by default with visual debugger off.
TEST_F(VisualDebuggerTest, DefaultDisabledNoExecute) {
  const char* kStrA = "anno_A";
  // These integers are mutated on a function invocation.
  int count_a = 0;

  auto get_a_string = [&count_a, &kStrA]() {
    count_a++;
    return std::string(kStrA);
  };

  DBG_DRAW_TEXT(kStrA, gfx::Point(), get_a_string());
  DBG_LOG(kStrA, "%s", get_a_string().c_str());
  EXPECT_EQ(0, count_a);

  EXPECT_EQ(get_a_string(), kStrA);
  EXPECT_EQ(1, count_a);
}

// For optimization purposes the flag fbool values return false as a constexpr.
// This allows the compiler to constant propagate and remove unused codepaths.
static_assert(flag_default_value_check() == false,
              "Default value when debugger is disabled is false.");

#endif