Skip to content

Commit

Permalink
Added test to ensure we don't send url at HistoryDeleteDirectiveSpeci…
Browse files Browse the repository at this point in the history
…fics::UrlDirective
  • Loading branch information
AlexeyBarabash committed Oct 12, 2023
1 parent 94082ef commit 577c76f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chromium_src/components/history/core/browser/sync/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+src/components/history/core/browser/sync/delete_directive_handler_unittest.cc",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Copyright (c) 2023 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 https://mozilla.org/MPL/2.0/. */

#include "src/components/history/core/browser/sync/delete_directive_handler_unittest.cc"

namespace history {
namespace {

// Check if patch for DeleteDirectiveHandler::CreateUrlDeleteDirective works.
// Create UrlDeleteDirective and ensure that url is in fact empty.
TEST_F(HistoryDeleteDirectiveHandlerTest,
BraveCreateUrlDeleteDirectiveOmitsUrl) {
syncer::FakeSyncChangeProcessor change_processor;

EXPECT_FALSE(
handler()
->MergeDataAndStartSyncing(
syncer::HISTORY_DELETE_DIRECTIVES, syncer::SyncDataList(),
std::make_unique<syncer::SyncChangeProcessorWrapperForTest>(
&change_processor))
.has_value());

bool create_directive_result =
handler()->CreateUrlDeleteDirective(GURL("https://brave.com"));
EXPECT_TRUE(create_directive_result);

ASSERT_EQ(1u, change_processor.changes().size());

const auto& specifics =
change_processor.changes()[0].sync_data().GetSpecifics();
ASSERT_TRUE(specifics.has_history_delete_directive());
const auto& history_delete_directive = specifics.history_delete_directive();
ASSERT_TRUE(history_delete_directive.has_url_directive());
EXPECT_FALSE(history_delete_directive.url_directive().has_url());
EXPECT_EQ(history_delete_directive.url_directive().url(), std::string());
}

} // namespace
} // namespace history
21 changes: 21 additions & 0 deletions components/history/core/browser/sync/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 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 https://mozilla.org/MPL/2.0/.

source_set("unit_tests") {
testonly = true
sources = [ "//components/history/core/browser/sync/delete_directive_handler_unittest.cc" ]
deps = [
"//base",
"//base/test:test_support",
"//components/history/core/browser:browser",
"//components/history/core/common",
"//components/history/core/test",
"//components/prefs:test_support",
"//components/sync",
"//components/sync:test_support",
"//testing/gtest",
"//url",
]
}
1 change: 1 addition & 0 deletions test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ test("brave_unit_tests") {
"//brave/components/de_amp/browser/test:unit_tests",
"//brave/components/debounce/browser/test:unit_tests",
"//brave/components/embedder_support:unit_tests",
"//brave/components/history/core/browser/sync:unit_tests",
"//brave/components/ipfs/buildflags",
"//brave/components/ipfs/test:brave_ipfs_unit_tests",
"//brave/components/json:brave_json_unit_tests",
Expand Down

0 comments on commit 577c76f

Please sign in to comment.