From 285bb8fac9beaf68fd54ded54e18d076fc2519a7 Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Mon, 14 Oct 2024 15:32:36 -0700 Subject: [PATCH] remove aichatthrottle unit test remnant --- browser/ai_chat/BUILD.gn | 19 ---- browser/ai_chat/ai_chat_throttle_unittest.cc | 103 ------------------- test/BUILD.gn | 1 - 3 files changed, 123 deletions(-) delete mode 100644 browser/ai_chat/ai_chat_throttle_unittest.cc diff --git a/browser/ai_chat/BUILD.gn b/browser/ai_chat/BUILD.gn index f882ac93f149..9930e54e1ebd 100644 --- a/browser/ai_chat/BUILD.gn +++ b/browser/ai_chat/BUILD.gn @@ -44,25 +44,6 @@ static_library("ai_chat") { } } -source_set("unit_tests") { - testonly = true - sources = [ "ai_chat_throttle_unittest.cc" ] - - deps = [ - "//base", - "//base/test:test_support", - "//brave/components/ai_chat/content/browser", - "//brave/components/ai_chat/core/common", - "//brave/components/constants", - "//chrome/common", - "//chrome/test:test_support", - "//content/public/browser", - "//content/test:test_support", - "//testing/gtest", - "//url", - ] -} - source_set("browser_tests") { if (!is_android) { testonly = true diff --git a/browser/ai_chat/ai_chat_throttle_unittest.cc b/browser/ai_chat/ai_chat_throttle_unittest.cc deleted file mode 100644 index 56c15595b358..000000000000 --- a/browser/ai_chat/ai_chat_throttle_unittest.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* 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 - -#include "base/test/scoped_feature_list.h" -#include "brave/components/ai_chat/content/browser/ai_chat_throttle.h" -#include "brave/components/ai_chat/core/common/features.h" -#include "chrome/test/base/testing_browser_process.h" -#include "chrome/test/base/testing_profile.h" -#include "chrome/test/base/testing_profile_manager.h" -#include "content/public/test/browser_task_environment.h" -#include "content/public/test/mock_navigation_handle.h" -#include "content/public/test/web_contents_tester.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "url/gurl.h" - -namespace ai_chat { - -namespace { -constexpr char kTestProfileName[] = "TestProfile"; -} // namespace - -class AiChatThrottleUnitTest : public testing::Test { - public: - AiChatThrottleUnitTest() = default; - AiChatThrottleUnitTest(const AiChatThrottleUnitTest&) = delete; - AiChatThrottleUnitTest& operator=(const AiChatThrottleUnitTest&) = delete; - ~AiChatThrottleUnitTest() override = default; - - void SetUp() override { - TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); - profile_manager_ = std::make_unique(browser_process); - ASSERT_TRUE(profile_manager_->SetUp()); - Profile* profile = profile_manager_->CreateTestingProfile(kTestProfileName); - - web_contents_ = - content::WebContentsTester::CreateTestWebContents(profile, nullptr); - - features_.InitAndEnableFeature(ai_chat::features::kAIChat); - } - - void TearDown() override { - web_contents_.reset(); - profile_manager_->DeleteTestingProfile(kTestProfileName); - } - - content::WebContents* web_contents() { return web_contents_.get(); } - - private: - content::BrowserTaskEnvironment task_environment_; - std::unique_ptr web_contents_; - std::unique_ptr profile_manager_; - base::test::ScopedFeatureList features_; -}; - -TEST_F(AiChatThrottleUnitTest, CancelNavigationFromTab) { - content::MockNavigationHandle test_handle(web_contents()); - - test_handle.set_url(GURL("chrome-untrusted://chat")); - -#if BUILDFLAG(IS_ANDROID) - ui::PageTransition transition = ui::PageTransitionFromInt( - ui::PageTransition::PAGE_TRANSITION_FROM_ADDRESS_BAR); -#else - ui::PageTransition transition = ui::PageTransitionFromInt( - ui::PageTransition::PAGE_TRANSITION_FROM_ADDRESS_BAR | - ui::PageTransition::PAGE_TRANSITION_TYPED); -#endif - - test_handle.set_page_transition(transition); - - std::unique_ptr throttle = - AiChatThrottle::MaybeCreateThrottleFor(&test_handle); - EXPECT_NE(throttle.get(), nullptr); - - EXPECT_EQ(content::NavigationThrottle::CANCEL_AND_IGNORE, - throttle->WillStartRequest().action()); -} - -TEST_F(AiChatThrottleUnitTest, AllowNavigationFromPanel) { - content::MockNavigationHandle test_handle(web_contents()); - - test_handle.set_url(GURL("chrome-untrusted://chat")); - -#if BUILDFLAG(IS_ANDROID) - ui::PageTransition transition = - ui::PageTransitionFromInt(ui::PageTransition::PAGE_TRANSITION_FROM_API); -#else - ui::PageTransition transition = ui::PageTransitionFromInt( - ui::PageTransition::PAGE_TRANSITION_AUTO_TOPLEVEL); -#endif - - test_handle.set_page_transition(transition); - - std::unique_ptr throttle = - AiChatThrottle::MaybeCreateThrottleFor(&test_handle); - EXPECT_EQ(throttle.get(), nullptr); -} - -} // namespace ai_chat diff --git a/test/BUILD.gn b/test/BUILD.gn index 2e1726abcb48..7feaeef13918 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -365,7 +365,6 @@ test("brave_unit_tests") { if (enable_ai_chat) { deps += [ - "//brave/browser/ai_chat:unit_tests", "//brave/browser/ui/ai_chat:unit_tests", "//brave/components/ai_chat/core/browser:unit_tests", "//brave/components/ai_chat/core/common:unit_tests",