Commit 9ce7f03f authored by Caleb Rouleau's avatar Caleb Rouleau Committed by Commit Bot

Reland "Fixed first_run test failure because of the global variables"

This reverts commit 242fe9d5.

Reason for revert: The bot is working again before the revert when in: https://uberchromegw.corp.google.com/i/chromium.mac/builders/Mac10.10%20Tests/builds/30249

Original change's description:
> Revert "Fixed first_run test failure because of the global variables"
> 
> This reverts commit 8d01fd2f.
> 
> Reason for revert: crbug.com/822316 looks like it broke net_unittests?
> 
> bug: 822316
> 
> Original change's description:
> > Fixed first_run test failure because of the global variables
> > 
> > Fixed typical problem with unit tests and global variables.
> > If unit test modifies global variables then it can affect other tests
> > which are runned in the same process. Added reseting of the global
> > variables to avoid this.
> > 
> > Change-Id: I2045700473ac074209f4d48a6cedbd3dad24ccd5
> > Reviewed-on: https://chromium-review.googlesource.com/952905
> > Commit-Queue: Alexander Yashkin <a-v-y@yandex-team.ru>
> > Reviewed-by: Carlos Pizano <cpu@chromium.org>
> > Reviewed-by: Gabriel Charette <gab@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#543345}
> 
> TBR=gab@chromium.org,cpu@chromium.org,a-v-y@yandex-team.ru,vitreb@yandex-team.ru
> 
> Change-Id: I616e5415b0e786dc5bd3075f1360b31a6452e256
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/964621
> Reviewed-by: Caleb Rouleau <crouleau@chromium.org>
> Commit-Queue: Caleb Rouleau <crouleau@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#543423}

TBR=gab@chromium.org,cpu@chromium.org,crouleau@chromium.org,a-v-y@yandex-team.ru,vitreb@yandex-team.ru

Change-Id: I3e37c027b65d1df944d3246dd6c8314d9dc9a7ee
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/963853Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Commit-Queue: Caleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543430}
parent 84a837c4
...@@ -84,6 +84,10 @@ bool g_should_do_autofill_personal_data_manager_first_run = false; ...@@ -84,6 +84,10 @@ bool g_should_do_autofill_personal_data_manager_first_run = false;
first_run::internal::FirstRunState g_first_run = first_run::internal::FirstRunState g_first_run =
first_run::internal::FIRST_RUN_UNKNOWN; first_run::internal::FIRST_RUN_UNKNOWN;
// Cached first run sentinel creation time.
// Used to avoid excess file operations.
base::Time g_cached_sentinel_creation_time;
// This class acts as an observer for the ImporterProgressObserver::ImportEnded // This class acts as an observer for the ImporterProgressObserver::ImportEnded
// callback. When the import process is started, certain errors may cause // callback. When the import process is started, certain errors may cause
// ImportEnded() to be called synchronously, but the typical case is that // ImportEnded() to be called synchronously, but the typical case is that
...@@ -449,8 +453,14 @@ void CreateSentinelIfNeeded() { ...@@ -449,8 +453,14 @@ void CreateSentinelIfNeeded() {
} }
base::Time GetFirstRunSentinelCreationTime() { base::Time GetFirstRunSentinelCreationTime() {
static const base::Time cached_time = ReadFirstRunSentinelCreationTime(); if (g_cached_sentinel_creation_time.is_null())
return cached_time; g_cached_sentinel_creation_time = ReadFirstRunSentinelCreationTime();
return g_cached_sentinel_creation_time;
}
void ResetCachedSentinelDataForTesting() {
g_cached_sentinel_creation_time = base::Time();
g_first_run = first_run::internal::FIRST_RUN_UNKNOWN;
} }
void SetShouldShowWelcomePage() { void SetShouldShowWelcomePage() {
......
...@@ -104,6 +104,10 @@ void CreateSentinelIfNeeded(); ...@@ -104,6 +104,10 @@ void CreateSentinelIfNeeded();
// permission on the sequence it is first called on. // permission on the sequence it is first called on.
base::Time GetFirstRunSentinelCreationTime(); base::Time GetFirstRunSentinelCreationTime();
// Resets the first run status and cached first run sentinel creation time.
// This is needed for unit tests which are runned in the same process.
void ResetCachedSentinelDataForTesting();
// Sets a flag that will cause ShouldShowWelcomePage to return true // Sets a flag that will cause ShouldShowWelcomePage to return true
// exactly once, so that the browser loads the welcome tab once the // exactly once, so that the browser loads the welcome tab once the
// message loop gets going. // message loop gets going.
......
...@@ -22,6 +22,11 @@ class FirstRunTest : public testing::Test { ...@@ -22,6 +22,11 @@ class FirstRunTest : public testing::Test {
FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {} FirstRunTest() : user_data_dir_override_(chrome::DIR_USER_DATA) {}
~FirstRunTest() override {} ~FirstRunTest() override {}
void TearDown() override {
first_run::ResetCachedSentinelDataForTesting();
Test::TearDown();
}
private: private:
base::ScopedPathOverride user_data_dir_override_; base::ScopedPathOverride user_data_dir_override_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment