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

Browser test fixes #23657

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Browser test fixes #23657

wants to merge 29 commits into from

Conversation

bridiver
Copy link
Collaborator

@bridiver bridiver commented May 14, 2024

Resolves brave/brave-browser#38325

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@bridiver bridiver requested a review from a team as a code owner May 14, 2024 22:50
}

void SetUpOnMainThread() override {
mock_cert_verifier_.mock_cert_verifier()->set_default_result(net::OK);
host_resolver()->AddRule("*:*", "127.0.0.1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed but not added back - does it need to be added above under SetUpOnMainThread?

brave::RegisterPathProvider();

// Reuse upstream test files in content.
content::RegisterPathProvider();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this weird behavior (registering our path provider... then content path provider) needed because paths were registered so many times? Really curious why that was added 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of the path registration stuff was a mess. It's fixed now

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building and running tests to try it out - but went over ever change, left some comments.

Changes LGTM. Super nice cleanup in chromium_src/chrome/app/chrome_main_delegate.cc! 😄

Also nice to have the override simplification in chromium_src/chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc

@bsclifton
Copy link
Member

Probably already known - but I get a ton of crashes when running npm run test -- brave_unit_tests. I didn't try npm run test -- brave_browser_tests yet

@@ -71,11 +71,6 @@ class BlobUrlBrowserTestBase : public EphemeralStorageBrowserTest {
};
using FramesWithRegisteredBlobs = std::vector<RenderFrameHostBlobData>;

void SetUpOnMainThread() override {
EphemeralStorageBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(embedded_test_server()->Start());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't follow why this is moved

Copy link
Collaborator Author

@bridiver bridiver May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to resolve several issues across tests that subclass EphemeralStorageBrowserTest so I moved it there to simplify things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@aseren aseren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brave Ads LGTM

Copy link
Contributor

github-actions bot commented Jun 3, 2024

[puLL-Merge] - brave/brave-core@23657

Here is my review of the PR changes:

Description

This PR makes several changes related to how Brave registers custom path providers and sets up embedded test servers for browser tests. The main changes are:

  1. Move the RegisterPathProvider function from brave_paths.cc to an override in chrome_paths.cc. This allows removing the separate brave_paths.cc file.

  2. Remove calls to brave::RegisterPathProvider() from many browser test setup methods. Instead, move the test data directory logic into SetUpOnMainThread().

  3. Remove the BraveCommandLineHelper class and its unit tests, moving the logic into BraveMainDelegate::BasicStartupComplete() directly.

The motivation seems to be simplifying the path provider registration and browser test setup code.

Changes

Changes

  • app/:

    • Remove BraveCommandLineHelper class and tests
    • Move logic from BraveCommandLineHelper into BraveMainDelegate::BasicStartupComplete()
    • Define BraveMainDelegate::BasicStartupComplete() directly instead of using BasicStartupComplete_ChromiumImpl macro
  • browser/, components/:

    • Remove many calls to brave::RegisterPathProvider() from browser tests
    • Move test data directory logic from SetUp() to SetUpOnMainThread() in several browser tests
    • Fix a few test server setup issues
  • chromium_src/chrome/app/:

    • Remove unused includes and macro logic from chrome_main_delegate.cc
    • Include brave_main_delegate.cc directly
  • chromium_src/chrome/common/:

    • Move RegisterPathProvider to an override in chrome_paths.cc
  • components/constants/:

    • Delete brave_paths.cc, moving functionality to chrome_paths.cc
    • Update comments in brave_paths.h

Let me know if you have any other questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants