Skip to content

Commit

Permalink
Explicitly call TestingProfile::Builder::SetIsNewProfile() from tests
Browse files Browse the repository at this point in the history
Before Chromium 90, both TestingProfile and TestingProfile::Builder did
use base::Optional<bool> for their internal |is_new_profile| attribute,
and calling TestingProfile::IsNewProfile() without having explicitly
provided a value for |is_new_profile| via OverrideIsNewProfile() would
result on returning the value returned by Profile::IsNewProfile():

  bool TestingProfile::IsNewProfile() const {
    if (is_new_profile_.has_value())
      return is_new_profile_.value();
    return Profile::IsNewProfile();
  }

But now that Profile::IsNewProfile() is a pure virtual function, the
|is_new_profile| attribute of TestingProfile is no longer an optional
value, but a bool initialized to false. Therefore, it is now mandatory
to initialize its counterpart in TestingProfile::Builder explicitly in
order to make it clear that we're building a new testing profile.

Chromium change:

https://chromium.googlesource.com/chromium/src.git/+/52208fa33df1dc2174fb044cf777eeecad38838d

commit 52208fa33df1dc2174fb044cf777eeecad38838d
Author: Glen Robertson <glenrob@chromium.org>
Date:   Fri Jan 15 07:10:38 2021 +0000

    Push Profile::IsNewProfile down to subclasses, remove dep on first_run.

    TestingProfile::IsNewProfile now defaults to false instead of defaulting
    to the impl's behaviour when not overridden.

    profile.cc's inclusion of first_run.h was its last dependency on
    //c/b/... except for constants that have separate GN targets, and
    profile_observer. Removing the dependency allows profile.{cc,h} and
    profile_observer.h to be moved from //c/b:browser to a separate GN
    target (will be done in subsequent CL). This will let us break
    dependency cycles and improve modularization of the codebase.

    Bug: 1149277
  • Loading branch information
mariospr committed Jan 29, 2021
1 parent 10e370a commit 6bd289c
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TEST(AccountConsistencyDisabledTest, NewProfile) {
// turned on to 100% of the user base and is no longer needed.
// See 36417aa39a5e8484b23f1ec927bfda23465f4f21
TestingProfile::Builder profile_builder;
profile_builder.SetIsNewProfile(true);
{
TestingPrefStore* user_prefs = new TestingPrefStore();

Expand Down

0 comments on commit 6bd289c

Please sign in to comment.