Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 ChromeRenderViewHostTestHarness::SetUp(); |
|
groby-ooo-7-16
2017/04/24 19:12:46
Why is the order of RVHTest setup and TranslateSer
Roger McFarlane (Chromium)
2017/04/24 20:31:34
RVHTest setup sets up the threading and message lo
| |
| 458 | 459 |
| 459 // Clears the translate script so it is fetched everytime and sets the | 460 // Clears the translate script so it is fetched everytime and sets the |
| 460 // expiration delay to a large value by default (in case it was zeroed in a | 461 // expiration delay to a large value by default (in case it was zeroed in a |
| 461 // previous test). | 462 // previous test). |
| 463 TranslateService::InitializeForTesting(); | |
| 462 translate::TranslateDownloadManager* download_manager = | 464 translate::TranslateDownloadManager* download_manager = |
| 463 translate::TranslateDownloadManager::GetInstance(); | 465 translate::TranslateDownloadManager::GetInstance(); |
| 464 download_manager->ClearTranslateScriptForTesting(); | 466 download_manager->ClearTranslateScriptForTesting(); |
| 465 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); | 467 download_manager->SetTranslateScriptExpirationDelay(60 * 60 * 1000); |
| 468 download_manager->set_request_context(new net::TestURLRequestContextGetter( | |
| 469 base::ThreadTaskRunnerHandle::Get())); | |
| 466 | 470 |
| 467 ChromeRenderViewHostTestHarness::SetUp(); | |
| 468 InfoBarService::CreateForWebContents(web_contents()); | 471 InfoBarService::CreateForWebContents(web_contents()); |
| 469 ChromeTranslateClient::CreateForWebContents(web_contents()); | 472 ChromeTranslateClient::CreateForWebContents(web_contents()); |
| 470 ChromeTranslateClient::FromWebContents(web_contents()) | 473 ChromeTranslateClient::FromWebContents(web_contents()) |
| 471 ->translate_driver() | 474 ->translate_driver() |
| 472 .set_translate_max_reload_attempts(0); | 475 .set_translate_max_reload_attempts(0); |
| 473 | 476 |
| 474 notification_registrar_.Add( | 477 notification_registrar_.Add( |
| 475 this, | 478 this, |
| 476 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 479 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
| 477 content::Source<InfoBarService>(infobar_service())); | 480 content::Source<InfoBarService>(infobar_service())); |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1747 | 1750 |
| 1748 // Check the bubble exists instead of the infobar. | 1751 // Check the bubble exists instead of the infobar. |
| 1749 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1752 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1750 ASSERT_TRUE(infobar == NULL); | 1753 ASSERT_TRUE(infobar == NULL); |
| 1751 TranslateBubbleModel* bubble = factory->model(); | 1754 TranslateBubbleModel* bubble = factory->model(); |
| 1752 ASSERT_TRUE(bubble != NULL); | 1755 ASSERT_TRUE(bubble != NULL); |
| 1753 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1756 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
| 1754 bubble->GetViewState()); | 1757 bubble->GetViewState()); |
| 1755 } | 1758 } |
| 1756 #endif // defined(USE_AURA) | 1759 #endif // defined(USE_AURA) |
| OLD | NEW |