chromium/net/base/test_completion_callback_unittest.cc

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

// Illustrates how to use net::TestCompletionCallback.

#include "net/base/test_completion_callback.h"

#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/task/single_thread_task_runner.h"
#include "net/base/completion_once_callback.h"
#include "net/test/test_with_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"

namespace net {

namespace {

const int kMagicResult =;

void CallClosureAfterCheckingResult(base::OnceClosure closure,
                                    bool* did_check_result,
                                    int result) {}

// ExampleEmployer is a toy version of HostResolver
// TODO: restore damage done in extracting example from real code
// (e.g. bring back real destructor, bring back comments)
class ExampleEmployer {};

// Helper class; this is how ExampleEmployer schedules work.
class ExampleEmployer::ExampleWorker
    : public base::RefCountedThreadSafe<ExampleWorker> {};

void ExampleEmployer::ExampleWorker::DoWork() {}

void ExampleEmployer::ExampleWorker::DoCallback() {}

ExampleEmployer::ExampleEmployer() = default;

ExampleEmployer::~ExampleEmployer() = default;

bool ExampleEmployer::DoSomething(CompletionOnceCallback callback) {}

}  // namespace

class TestCompletionCallbackTest : public PlatformTest,
                                   public WithTaskEnvironment {};

TEST_F(TestCompletionCallbackTest, Simple) {}

TEST_F(TestCompletionCallbackTest, Closure) {}

// TODO: test deleting ExampleEmployer while work outstanding

}  // namespace net