Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build of upstream Chromium's unit_tests & browser_tests targets #7899

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ GURL GetSelectionNavigationURL(Profile* profile, const base::string16& text) {
return match.destination_url;
}

base::OnceCallback<void(BraveRenderViewContextMenu*)>*
BraveGetMenuShownCallback() {
static base::NoDestructor<
base::OnceCallback<void(BraveRenderViewContextMenu*)>>
callback;
return callback.get();
}

} // namespace

void RenderViewContextMenu::RegisterMenuShownCallbackForTesting(
base::OnceCallback<void(BraveRenderViewContextMenu*)> cb) {
*BraveGetMenuShownCallback() = std::move(cb);
}

#define BRAVE_APPEND_SEARCH_PROVIDER \
if (GetProfile()->IsOffTheRecord()) { \
selection_navigation_url_ = \
Expand All @@ -50,10 +63,13 @@ GURL GetSelectionNavigationURL(Profile* profile, const base::string16& text) {

// Use our subclass to initialize SpellingOptionsSubMenuObserver.
#define SpellingOptionsSubMenuObserver BraveSpellingOptionsSubMenuObserver
#define RegisterMenuShownCallbackForTesting \
RegisterMenuShownCallbackForTesting_unused

#include "../../../../../chrome/browser/renderer_context_menu/render_view_context_menu.cc"

#undef SpellingOptionsSubMenuObserver
#undef RegisterMenuShownCallbackForTesting

// Make it clear which class we mean here.
#undef RenderViewContextMenu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@

// Get the Chromium declaration.
#define RenderViewContextMenu RenderViewContextMenu_Chromium

class BraveRenderViewContextMenu;

#define RegisterMenuShownCallbackForTesting \
RegisterMenuShownCallbackForTesting( \
base::OnceCallback<void(BraveRenderViewContextMenu*)> cb); \
static void RegisterMenuShownCallbackForTesting_unused
#include "../../../../../chrome/browser/renderer_context_menu/render_view_context_menu.h"
#undef RegisterMenuShownCallbackForTesting
#undef RenderViewContextMenu

// Declare our own subclass with overridden methods.
Expand Down
8 changes: 8 additions & 0 deletions chromium_src/chrome/test/base/testing_profile.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "../../../../../chrome/test/base/testing_profile.cc"

#include "brave/test/base/brave_testing_profile.cc"
13 changes: 13 additions & 0 deletions chromium_src/chrome/test/base/testing_profile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_CHROMIUM_SRC_CHROME_TEST_BASE_TESTING_PROFILE_H_
#define BRAVE_CHROMIUM_SRC_CHROME_TEST_BASE_TESTING_PROFILE_H_

#include "../../../../../chrome/test/base/testing_profile.h"

#include "brave/test/base/brave_testing_profile.h"

#endif // BRAVE_CHROMIUM_SRC_CHROME_TEST_BASE_TESTING_PROFILE_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.

#include "brave/components/sync_device_info/brave_device_info.h"

#include "../../../../components/sync_device_info/fake_device_info_tracker.cc"

namespace syncer {

void FakeDeviceInfoTracker::DeleteDeviceInfo(const std::string& client_id,
base::OnceClosure callback) {}

std::vector<std::unique_ptr<BraveDeviceInfo>>
FakeDeviceInfoTracker::GetAllBraveDeviceInfo() const {
return std::vector<std::unique_ptr<BraveDeviceInfo>>();
}

} // namespace syncer
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_FAKE_DEVICE_INFO_TRACKER_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_FAKE_DEVICE_INFO_TRACKER_H_

#include "brave/components/sync_device_info/brave_device_info.h"
#include "components/sync_device_info/device_info_tracker.h"

#define ForcePulseForTest \
DeleteDeviceInfo(const std::string& client_id, base::OnceClosure callback) \
override; \
std::vector<std::unique_ptr<BraveDeviceInfo>> GetAllBraveDeviceInfo() \
const override; \
void ForcePulseForTest

#include "../../../../components/sync_device_info/fake_device_info_tracker.h"

#undef ForcePulseForTest

#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_DEVICE_INFO_FAKE_DEVICE_INFO_TRACKER_H_
4 changes: 2 additions & 2 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ static_library("brave_test_support_unit") {
testonly = true

sources = [
"base/brave_testing_profile.cc",
"base/brave_testing_profile.h",
# Not including brave_testing_profile.{h,cc} here, they need to be pulled
# via an override for testing_profile.{h,cc} for upstream tests to build.
"base/brave_unit_test_suite.cc",
"base/brave_unit_test_suite.h",
"base/run_all_unittests.cc",
Expand Down