[AI Chat]: AiChat ==> AIChat to make running tests easier (#27242)

This commit is contained in:
Jay Harris
2025-01-16 09:01:29 +13:00
committed by GitHub
parent f4d205a7b6
commit e7c51aa2ac
6 changed files with 32 additions and 32 deletions
+3 -3
View File
@@ -20,9 +20,9 @@
namespace ai_chat {
class AiChatBrowserTest : public InProcessBrowserTest {
class AIChatBrowserTest : public InProcessBrowserTest {
public:
AiChatBrowserTest() = default;
AIChatBrowserTest() = default;
void SetUpOnMainThread() override {
base::FilePath test_data_dir =
@@ -81,7 +81,7 @@ class AiChatBrowserTest : public InProcessBrowserTest {
net::EmbeddedTestServer https_server_{net::EmbeddedTestServer::TYPE_HTTPS};
};
IN_PROC_BROWSER_TEST_F(AiChatBrowserTest, YoutubeNavigations) {
IN_PROC_BROWSER_TEST_F(AIChatBrowserTest, YoutubeNavigations) {
const GURL url("https://www.youtube.com/youtube.html");
ui_test_utils::NavigateToURLWithDisposition(
+16 -16
View File
@@ -27,13 +27,13 @@ constexpr char kTestProfileName[] = "TestProfile";
} // namespace
class AiChatThrottleUnitTest : public testing::Test,
class AIChatThrottleUnitTest : public testing::Test,
public ::testing::WithParamInterface<bool> {
public:
AiChatThrottleUnitTest() = default;
AiChatThrottleUnitTest(const AiChatThrottleUnitTest&) = delete;
AiChatThrottleUnitTest& operator=(const AiChatThrottleUnitTest&) = delete;
~AiChatThrottleUnitTest() override = default;
AIChatThrottleUnitTest() = default;
AIChatThrottleUnitTest(const AIChatThrottleUnitTest&) = delete;
AIChatThrottleUnitTest& operator=(const AIChatThrottleUnitTest&) = delete;
~AIChatThrottleUnitTest() override = default;
void SetUp() override {
TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
@@ -68,13 +68,13 @@ class AiChatThrottleUnitTest : public testing::Test,
INSTANTIATE_TEST_SUITE_P(
,
AiChatThrottleUnitTest,
AIChatThrottleUnitTest,
::testing::Bool(),
[](const testing::TestParamInfo<AiChatThrottleUnitTest::ParamType>& info) {
[](const testing::TestParamInfo<AIChatThrottleUnitTest::ParamType>& info) {
return base::StrCat({"History", info.param ? "Enabled" : "Disabled"});
});
TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) {
TEST_P(AIChatThrottleUnitTest, CancelNavigationFromTab) {
content::MockNavigationHandle test_handle(web_contents());
test_handle.set_url(GURL(kAIChatUIURL));
@@ -85,8 +85,8 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) {
test_handle.set_page_transition(transition);
std::unique_ptr<AiChatThrottle> throttle =
AiChatThrottle::MaybeCreateThrottleFor(&test_handle);
std::unique_ptr<AIChatThrottle> throttle =
AIChatThrottle::MaybeCreateThrottleFor(&test_handle);
#if !BUILDFLAG(IS_ANDROID)
if (IsAIChatHistoryEnabled()) {
@@ -101,7 +101,7 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationFromTab) {
#endif
}
TEST_P(AiChatThrottleUnitTest, CancelNavigationToFrame) {
TEST_P(AIChatThrottleUnitTest, CancelNavigationToFrame) {
content::MockNavigationHandle test_handle(web_contents());
test_handle.set_url(GURL(kAIChatUntrustedConversationUIURL));
@@ -112,8 +112,8 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationToFrame) {
test_handle.set_page_transition(transition);
std::unique_ptr<AiChatThrottle> throttle =
AiChatThrottle::MaybeCreateThrottleFor(&test_handle);
std::unique_ptr<AIChatThrottle> throttle =
AIChatThrottle::MaybeCreateThrottleFor(&test_handle);
#if !BUILDFLAG(IS_ANDROID)
EXPECT_EQ(content::NavigationThrottle::CANCEL_AND_IGNORE,
throttle->WillStartRequest().action());
@@ -122,7 +122,7 @@ TEST_P(AiChatThrottleUnitTest, CancelNavigationToFrame) {
#endif
}
TEST_P(AiChatThrottleUnitTest, AllowNavigationFromPanel) {
TEST_P(AIChatThrottleUnitTest, AllowNavigationFromPanel) {
content::MockNavigationHandle test_handle(web_contents());
test_handle.set_url(GURL(kAIChatUIURL));
@@ -137,8 +137,8 @@ TEST_P(AiChatThrottleUnitTest, AllowNavigationFromPanel) {
test_handle.set_page_transition(transition);
std::unique_ptr<AiChatThrottle> throttle =
AiChatThrottle::MaybeCreateThrottleFor(&test_handle);
std::unique_ptr<AIChatThrottle> throttle =
AIChatThrottle::MaybeCreateThrottleFor(&test_handle);
EXPECT_EQ(throttle.get(), nullptr);
}
+1 -1
View File
@@ -1284,7 +1284,7 @@ BraveContentBrowserClient::CreateThrottlesForNavigation(
if (Profile::FromBrowserContext(context)->IsRegularProfile()) {
if (auto ai_chat_throttle =
ai_chat::AiChatThrottle::MaybeCreateThrottleFor(handle)) {
ai_chat::AIChatThrottle::MaybeCreateThrottleFor(handle)) {
throttles.push_back(std::move(ai_chat_throttle));
}
}
@@ -23,7 +23,7 @@
namespace ai_chat {
// static
std::unique_ptr<AiChatThrottle> AiChatThrottle::MaybeCreateThrottleFor(
std::unique_ptr<AIChatThrottle> AIChatThrottle::MaybeCreateThrottleFor(
content::NavigationHandle* navigation_handle) {
// The throttle's only purpose is to deny navigation in a Tab.
@@ -65,21 +65,21 @@ std::unique_ptr<AiChatThrottle> AiChatThrottle::MaybeCreateThrottleFor(
ui::PageTransition::PAGE_TRANSITION_FROM_ADDRESS_BAR)) {
return nullptr;
}
return std::make_unique<AiChatThrottle>(navigation_handle);
return std::make_unique<AIChatThrottle>(navigation_handle);
#endif // BUILDFLAG(IS_ANDROID)
}
AiChatThrottle::AiChatThrottle(content::NavigationHandle* handle)
AIChatThrottle::AIChatThrottle(content::NavigationHandle* handle)
: content::NavigationThrottle(handle) {}
AiChatThrottle::~AiChatThrottle() {}
AIChatThrottle::~AIChatThrottle() {}
AiChatThrottle::ThrottleCheckResult AiChatThrottle::WillStartRequest() {
AIChatThrottle::ThrottleCheckResult AIChatThrottle::WillStartRequest() {
return CANCEL_AND_IGNORE;
}
const char* AiChatThrottle::GetNameForLogging() {
return "AiChatThrottle";
const char* AIChatThrottle::GetNameForLogging() {
return "AIChatThrottle";
}
} // namespace ai_chat
@@ -17,12 +17,12 @@ class NavigationHandle;
namespace ai_chat {
// Prevents navigation to certain AI Chat URLs
class AiChatThrottle : public content::NavigationThrottle {
class AIChatThrottle : public content::NavigationThrottle {
public:
explicit AiChatThrottle(content::NavigationHandle* handle);
~AiChatThrottle() override;
explicit AIChatThrottle(content::NavigationHandle* handle);
~AIChatThrottle() override;
static std::unique_ptr<AiChatThrottle> MaybeCreateThrottleFor(
static std::unique_ptr<AIChatThrottle> MaybeCreateThrottleFor(
content::NavigationHandle* navigation_handle);
// content::NavigationThrottle:
@@ -1073,7 +1073,7 @@ TEST_F(SidebarServiceOrderingTest, LoadFromPrefsWalletBuiltInHidden) {
LoadFromPrefsTest(std::move(sidebar), items, expected_count);
}
TEST_F(SidebarServiceOrderingTest, LoadFromPrefsAiChatBuiltInNotListed) {
TEST_F(SidebarServiceOrderingTest, LoadFromPrefsAIChatBuiltInNotListed) {
base::Value::Dict sidebar =
base::test::ParseJsonDict(sidebar_builtin_ai_chat_not_listed_json);