Commit 0b22acf2 authored by ssid's avatar ssid Committed by Commit Bot

Fix bookmark view tests

Creating Profile will create storage partition, which will need mojo
initialized. So, move the init to test constructor. Network context also
requires local state, so move the local state scope over profile
creation.
ChromeDataUseMeasurement is never destroyed. So, make the observer
leaky.

BUG=943354

Change-Id: I6ad76d421bdd2c376117b92abf965857f6f3a2c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1720124Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: ssid <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681329}
parent 2d82c3a3
...@@ -289,6 +289,8 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { ...@@ -289,6 +289,8 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
BookmarkBarView::DisableAnimationsForTesting(true); BookmarkBarView::DisableAnimationsForTesting(true);
SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient()); SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient());
local_state_.reset(
new ScopedTestingLocalState(TestingBrowserProcess::GetGlobal()));
profile_.reset(new TestingProfile()); profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true); profile_->CreateBookmarkModel(true);
model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get()); model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get());
...@@ -298,8 +300,6 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { ...@@ -298,8 +300,6 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase {
Browser::CreateParams native_params(profile_.get(), true); Browser::CreateParams native_params(profile_.get(), true);
browser_ = CreateBrowserWithTestWindowForParams(&native_params); browser_ = CreateBrowserWithTestWindowForParams(&native_params);
local_state_.reset(new ScopedTestingLocalState(
TestingBrowserProcess::GetGlobal()));
model_->ClearStore(); model_->ClearStore();
bb_view_.reset(new BookmarkBarView(browser_.get(), NULL)); bb_view_.reset(new BookmarkBarView(browser_.get(), NULL));
......
...@@ -50,6 +50,11 @@ ViewEventTestBase::ViewEventTestBase() { ...@@ -50,6 +50,11 @@ ViewEventTestBase::ViewEventTestBase() {
// The TestingBrowserProcess must be created in the constructor because there // The TestingBrowserProcess must be created in the constructor because there
// are tests that require it before SetUp() is called. // are tests that require it before SetUp() is called.
TestingBrowserProcess::CreateInstance(); TestingBrowserProcess::CreateInstance();
// Mojo is initialized here similar to how each browser test case initializes
// Mojo when starting. This only works because each interactive_ui_test runs
// in a new process.
mojo::core::Init();
} }
void ViewEventTestBase::Done() { void ViewEventTestBase::Done() {
...@@ -63,11 +68,6 @@ void ViewEventTestBase::SetUpTestCase() { ...@@ -63,11 +68,6 @@ void ViewEventTestBase::SetUpTestCase() {
} }
void ViewEventTestBase::SetUp() { void ViewEventTestBase::SetUp() {
// Mojo is initialized here similar to how each browser test case initializes
// Mojo when starting. This only works because each interactive_ui_test runs
// in a new process.
mojo::core::Init();
ui::InitializeInputMethodForTesting(); ui::InitializeInputMethodForTesting();
// The ContextFactory must exist before any Compositors are created. // The ContextFactory must exist before any Compositors are created.
......
...@@ -57,7 +57,7 @@ DataUseMeasurement::DataUseMeasurement( ...@@ -57,7 +57,7 @@ DataUseMeasurement::DataUseMeasurement(
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(network_connection_tracker_); DCHECK(network_connection_tracker_);
network_connection_tracker_->AddNetworkConnectionObserver(this); network_connection_tracker_->AddLeakyNetworkConnectionObserver(this);
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
int64_t bytes = 0; int64_t bytes = 0;
......
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