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

Side by Side Diff: chrome/browser/translate/translate_manager_render_view_host_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 unified diff | Download patch
« no previous file with comments | « no previous file | components/translate/core/browser/ranker_model_loader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <tuple> 10 #include <tuple>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/public/browser/notification_registrar.h" 53 #include "content/public/browser/notification_registrar.h"
54 #include "content/public/browser/web_contents.h" 54 #include "content/public/browser/web_contents.h"
55 #include "content/public/common/browser_side_navigation_policy.h" 55 #include "content/public/common/browser_side_navigation_policy.h"
56 #include "content/public/common/url_constants.h" 56 #include "content/public/common/url_constants.h"
57 #include "content/public/test/test_renderer_host.h" 57 #include "content/public/test/test_renderer_host.h"
58 #include "mojo/public/cpp/bindings/binding.h" 58 #include "mojo/public/cpp/bindings/binding.h"
59 #include "net/base/net_errors.h" 59 #include "net/base/net_errors.h"
60 #include "net/url_request/test_url_fetcher_factory.h" 60 #include "net/url_request/test_url_fetcher_factory.h"
61 #include "net/url_request/url_fetcher_delegate.h" 61 #include "net/url_request/url_fetcher_delegate.h"
62 #include "net/url_request/url_request_status.h" 62 #include "net/url_request/url_request_status.h"
63 #include "net/url_request/url_request_test_util.h"
63 #include "testing/gmock/include/gmock/gmock.h" 64 #include "testing/gmock/include/gmock/gmock.h"
64 #include "third_party/WebKit/public/web/WebContextMenuData.h" 65 #include "third_party/WebKit/public/web/WebContextMenuData.h"
65 #include "url/gurl.h" 66 #include "url/gurl.h"
66 67
67 #if !defined(USE_AURA) 68 #if !defined(USE_AURA)
68 #include "components/translate/core/browser/translate_infobar_delegate.h" 69 #include "components/translate/core/browser/translate_infobar_delegate.h"
69 #endif 70 #endif
70 71
71 namespace { 72 namespace {
72 73
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type); 448 DCHECK_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, type);
448 removed_infobars_.insert( 449 removed_infobars_.insert(
449 content::Details<infobars::InfoBar::RemovedDetails>( 450 content::Details<infobars::InfoBar::RemovedDetails>(
450 details)->first->delegate()); 451 details)->first->delegate());
451 } 452 }
452 453
453 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&)); 454 MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
454 455
455 protected: 456 protected:
456 virtual void SetUp() { 457 virtual void SetUp() {
457 TranslateService::InitializeForTesting(); 458 // Setup the test environment, including the threads and message loops. This
459 // must be done before base::ThreadTaskRunnerHandle::Get() is called when
460 // setting up the net::TestURLRequestContextGetter below.
461 ChromeRenderViewHostTestHarness::SetUp();
458 462
459 // Clears the translate script so it is fetched everytime and sets the 463 // Clears the translate script so it is fetched every time and sets the
460 // expiration delay to a large value by default (in case it was zeroed in a 464 // expiration delay to a large value by default (in case it was zeroed in a
461 // previous test). 465 // previous test).
466 TranslateService::InitializeForTesting();
462 translate::TranslateDownloadManager* download_manager = 467 translate::TranslateDownloadManager* download_manager =
463 translate::TranslateDownloadManager::GetInstance(); 468 translate::TranslateDownloadManager::GetInstance();
464 download_manager->ClearTranslateScriptForTesting(); 469 download_manager->ClearTranslateScriptForTesting();
465 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); 470 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000);
471 download_manager->set_request_context(new net::TestURLRequestContextGetter(
472 base::ThreadTaskRunnerHandle::Get()));
466 473
467 ChromeRenderViewHostTestHarness::SetUp();
468 InfoBarService::CreateForWebContents(web_contents()); 474 InfoBarService::CreateForWebContents(web_contents());
469 ChromeTranslateClient::CreateForWebContents(web_contents()); 475 ChromeTranslateClient::CreateForWebContents(web_contents());
470 ChromeTranslateClient::FromWebContents(web_contents()) 476 ChromeTranslateClient::FromWebContents(web_contents())
471 ->translate_driver() 477 ->translate_driver()
472 .set_translate_max_reload_attempts(0); 478 .set_translate_max_reload_attempts(0);
473 479
474 notification_registrar_.Add( 480 notification_registrar_.Add(
475 this, 481 this,
476 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 482 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
477 content::Source<InfoBarService>(infobar_service())); 483 content::Source<InfoBarService>(infobar_service()));
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 1753
1748 // Check the bubble exists instead of the infobar. 1754 // Check the bubble exists instead of the infobar.
1749 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); 1755 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
1750 ASSERT_TRUE(infobar == NULL); 1756 ASSERT_TRUE(infobar == NULL);
1751 TranslateBubbleModel* bubble = factory->model(); 1757 TranslateBubbleModel* bubble = factory->model();
1752 ASSERT_TRUE(bubble != NULL); 1758 ASSERT_TRUE(bubble != NULL);
1753 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, 1759 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING,
1754 bubble->GetViewState()); 1760 bubble->GetViewState());
1755 } 1761 }
1756 #endif // defined(USE_AURA) 1762 #endif // defined(USE_AURA)
OLDNEW
« no previous file with comments | « no previous file | components/translate/core/browser/ranker_model_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698