Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: components/translate/core/browser/translate_script_unittest.cc

Issue 2839433002: [translate] Fix shutdown race for translate ranker model loader. (Closed)
Patch Set: fdoray part deux Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/translate/core/browser/translate_script_unittest.cc
diff --git a/components/translate/core/browser/translate_script_unittest.cc b/components/translate/core/browser/translate_script_unittest.cc
index e6547841f67f617526bee9e580d228880dfa462e..984c43a9e8371c20b41222e4ba2f5a224a62c589 100644
--- a/components/translate/core/browser/translate_script_unittest.cc
+++ b/components/translate/core/browser/translate_script_unittest.cc
@@ -8,6 +8,8 @@
#include "base/command_line.h"
#include "base/macros.h"
#include "base/strings/stringprintf.h"
+#include "base/test/scoped_task_scheduler.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/common/translate_switches.h"
@@ -15,6 +17,7 @@
#include "net/base/url_util.h"
#include "net/http/http_request_headers.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -29,6 +32,9 @@ class TranslateScriptTest : public testing::Test {
script_.reset(new TranslateScript);
DCHECK(script_.get());
TranslateDownloadManager::GetInstance()->set_application_locale("en");
+ TranslateDownloadManager::GetInstance()->set_request_context(
+ new net::TestURLRequestContextGetter(
+ base::ThreadTaskRunnerHandle::Get()));
}
void TearDown() override { script_.reset(); }
@@ -46,7 +52,13 @@ class TranslateScriptTest : public testing::Test {
void OnComplete(bool success, const std::string& script) {
}
+ // Sets up the task scheduling/task-runner environment for each test.
+ base::test::ScopedTaskScheduler scoped_task_scheduler_;
+
+ // The translate script.
std::unique_ptr<TranslateScript> script_;
+
+ // Factory to create programmatic URL fetchers.
net::TestURLFetcherFactory url_fetcher_factory_;
DISALLOW_COPY_AND_ASSIGN(TranslateScriptTest);
« no previous file with comments | « components/translate/core/browser/translate_ranker_impl.cc ('k') | components/translate/core/browser/translate_url_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698