Commit 2c59338e authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Make BrowserHistoryHandlerTest a ChromeRenderViewHostTestHarness.

This simplifies the test and allows it to pass in single process mash
due to extra setup in the test fixture.

(Technically, it also passes in single process mash without this change,
but would cease to do so after AuraTestSuite stops creating an
InputDeviceClient, which will soon happen.)

Bug: 905430
Change-Id: I0f9f630fdfd68e72bae1e652bad07bc18ec39d51
Reviewed-on: https://chromium-review.googlesource.com/c/1343348Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611896}
parent 514c49d4
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/browser_sync/test_profile_sync_service.h" #include "components/browser_sync/test_profile_sync_service.h"
#include "components/history/core/browser/browsing_history_service.h" #include "components/history/core/browser/browsing_history_service.h"
...@@ -29,13 +30,10 @@ ...@@ -29,13 +30,10 @@
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h" #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "components/signin/core/browser/fake_signin_manager.h" #include "components/signin/core/browser/fake_signin_manager.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_web_ui.h" #include "content/public/test/test_web_ui.h"
#include "net/http/http_status_code.h" #include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace { namespace {
...@@ -104,9 +102,27 @@ class BrowsingHistoryHandlerWithWebUIForTesting ...@@ -104,9 +102,27 @@ class BrowsingHistoryHandlerWithWebUIForTesting
} // namespace } // namespace
class BrowsingHistoryHandlerTest : public ::testing::Test { class BrowsingHistoryHandlerTest : public ChromeRenderViewHostTestHarness {
public: public:
void SetUp() override { void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
profile()->CreateBookmarkModel(false);
sync_service_ = static_cast<TestSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile()));
web_history_service_ = static_cast<history::FakeWebHistoryService*>(
WebHistoryServiceFactory::GetForProfile(profile()));
web_ui_.reset(new content::TestWebUI);
web_ui_->set_web_contents(web_contents());
}
void TearDown() override {
web_ui_.reset();
ChromeRenderViewHostTestHarness::TearDown();
}
content::BrowserContext* CreateBrowserContext() override {
TestingProfile::Builder builder; TestingProfile::Builder builder;
builder.AddTestingFactory( builder.AddTestingFactory(
ProfileOAuth2TokenServiceFactory::GetInstance(), ProfileOAuth2TokenServiceFactory::GetInstance(),
...@@ -118,27 +134,8 @@ class BrowsingHistoryHandlerTest : public ::testing::Test { ...@@ -118,27 +134,8 @@ class BrowsingHistoryHandlerTest : public ::testing::Test {
base::BindRepeating(&BuildFakeSyncService)); base::BindRepeating(&BuildFakeSyncService));
builder.AddTestingFactory(WebHistoryServiceFactory::GetInstance(), builder.AddTestingFactory(WebHistoryServiceFactory::GetInstance(),
base::BindRepeating(&BuildFakeWebHistoryService)); base::BindRepeating(&BuildFakeWebHistoryService));
profile_ = builder.Build(); return builder.Build().release();
profile_->CreateBookmarkModel(false);
sync_service_ = static_cast<TestSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile_.get()));
web_history_service_ = static_cast<history::FakeWebHistoryService*>(
WebHistoryServiceFactory::GetForProfile(profile_.get()));
web_contents_ = content::WebContents::Create(
content::WebContents::CreateParams(profile_.get()));
web_ui_.reset(new content::TestWebUI);
web_ui_->set_web_contents(web_contents_.get());
} }
void TearDown() override {
web_contents_.reset();
web_ui_.reset();
profile_.reset();
}
Profile* profile() { return profile_.get(); }
TestSyncService* sync_service() { return sync_service_; } TestSyncService* sync_service() { return sync_service_; }
history::WebHistoryService* web_history_service() { history::WebHistoryService* web_history_service() {
return web_history_service_; return web_history_service_;
...@@ -160,12 +157,9 @@ class BrowsingHistoryHandlerTest : public ::testing::Test { ...@@ -160,12 +157,9 @@ class BrowsingHistoryHandlerTest : public ::testing::Test {
return std::move(service); return std::move(service);
} }
content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestingProfile> profile_;
TestSyncService* sync_service_; TestSyncService* sync_service_;
history::FakeWebHistoryService* web_history_service_; history::FakeWebHistoryService* web_history_service_;
std::unique_ptr<content::TestWebUI> web_ui_; std::unique_ptr<content::TestWebUI> web_ui_;
std::unique_ptr<content::WebContents> web_contents_;
}; };
// Tests that BrowsingHistoryHandler is informed about WebHistoryService // Tests that BrowsingHistoryHandler is informed about WebHistoryService
......
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