chromium/chrome/browser/ui/webui/devtools/devtools_ui_data_source_unittest.cc

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

#include "chrome/browser/ui/webui/devtools/devtools_ui_data_source.h"

#include <memory>
#include <string_view>

#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/test/browser_task_environment.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

constexpr char kDevToolsUITestFrontEndUrl[] =;
constexpr char kDevToolsUITest404Response[] =;

GURL DevToolsUrl() {}

std::string DevToolsBundledPath(const std::string& path) {}

std::string DevToolsRemotePath(const std::string& path) {}

std::string DevToolsCustomPath(const std::string& path) {}

}  // namespace

class TestDevToolsDataSource : public DevToolsDataSource {};

class DevToolsUIDataSourceTest : public testing::Test {};

// devtools/bundled path.

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURL) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledURLWithQueryParam) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledFileURLWithSwitch) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBundledRemoteURLWithSwitch) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsInvalidBundledURL) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsInvalidBundledURLWithQueryParam) {}

// devtools/blank path

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBlankURL) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsBlankURLWithQueryParam) {}

// devtools/remote path

TEST_F(DevToolsUIDataSourceTest, TestDevToolsRemoteURLWithSwitch) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsRemoteFileURLWithSwitch) {}

TEST_F(DevToolsUIDataSourceTest,
       TestDevToolsRemoteFileURLWithSwitchAndServeRevParameters) {}

TEST_F(DevToolsUIDataSourceTest,
       TestDevToolsRemoteFileURLWithSwitchAndServeFileParameters) {}

TEST_F(DevToolsUIDataSourceTest,
       TestDevToolsRemoteFileURLWithSwitchAndServeInternalFileParameters) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsRemoteURL) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsRemoteURLWithQueryParam) {}

// devtools/custom path.

TEST_F(DevToolsUIDataSourceTest, TestDevToolsCustomURLWithNoSwitch) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsCustomURLWithSwitch) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsCustomURLWithSwitchAndQueryParam) {}

#if !DCHECK_IS_ON()
TEST_F(DevToolsUIDataSourceTest,
       TestDevToolsCustomURLWithSwitchAndInvalidServerURL) {
  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
      switches::kCustomDevtoolsFrontend, "invalid-server-url");
  const GURL path =
      DevToolsUrl().Resolve(DevToolsCustomPath(kDevToolsUITestFrontEndUrl));
  StartRequest(path.path());
  EXPECT_TRUE(data_received());
  ASSERT_TRUE(base::StartsWith(data(), kDevToolsUITest404Response,
                               base::CompareCase::SENSITIVE));
}
#endif

// devtools path (i.e. no route specified).

TEST_F(DevToolsUIDataSourceTest, TestDevToolsNoRoute) {}

TEST_F(DevToolsUIDataSourceTest, TestDevToolsNoRouteWithSwitch) {}

class DevToolsUIDataSourceWithTaskEnvTest : public testing::Test {};

TEST_F(DevToolsUIDataSourceWithTaskEnvTest,
       GotDataCallbackOwnsDevToolsDataSource) {}