| 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 "components/translate/core/browser/translate_script.h" | 5 #include "components/translate/core/browser/translate_script.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "components/translate/core/browser/translate_download_manager.h" | 10 #include "components/translate/core/browser/translate_download_manager.h" |
| 11 #include "components/translate/core/common/translate_switches.h" | 11 #include "components/translate/core/common/translate_switches.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/base/url_util.h" | 13 #include "net/base/url_util.h" |
| 14 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
| 15 #include "net/url_request/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 namespace translate { | 19 namespace translate { |
| 20 | 20 |
| 21 class TranslateScriptTest : public testing::Test { | 21 class TranslateScriptTest : public testing::Test { |
| 22 public: | 22 public: |
| 23 TranslateScriptTest() : testing::Test() {} | 23 TranslateScriptTest() : testing::Test() {} |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 virtual void SetUp() { | 26 void SetUp() override { |
| 27 script_.reset(new TranslateScript); | 27 script_.reset(new TranslateScript); |
| 28 DCHECK(script_.get()); | 28 DCHECK(script_.get()); |
| 29 TranslateDownloadManager::GetInstance()->set_application_locale("en"); | 29 TranslateDownloadManager::GetInstance()->set_application_locale("en"); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void TearDown() { | 32 void TearDown() override { script_.reset(); } |
| 33 script_.reset(); | |
| 34 } | |
| 35 | 33 |
| 36 void Request() { | 34 void Request() { |
| 37 script_->Request( | 35 script_->Request( |
| 38 base::Bind(&TranslateScriptTest::OnComplete, base::Unretained(this))); | 36 base::Bind(&TranslateScriptTest::OnComplete, base::Unretained(this))); |
| 39 } | 37 } |
| 40 | 38 |
| 41 net::TestURLFetcher* GetTestURLFetcher() { | 39 net::TestURLFetcher* GetTestURLFetcher() { |
| 42 return url_fetcher_factory_.GetFetcherByID(TranslateScript::kFetcherId); | 40 return url_fetcher_factory_.GetFetcherByID(TranslateScript::kFetcherId); |
| 43 } | 41 } |
| 44 | 42 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 ASSERT_TRUE(fetcher); | 113 ASSERT_TRUE(fetcher); |
| 116 | 114 |
| 117 GURL expected_url(script_url); | 115 GURL expected_url(script_url); |
| 118 GURL url = fetcher->GetOriginalURL(); | 116 GURL url = fetcher->GetOriginalURL(); |
| 119 EXPECT_TRUE(url.is_valid()); | 117 EXPECT_TRUE(url.is_valid()); |
| 120 EXPECT_EQ(expected_url.GetOrigin().spec(), url.GetOrigin().spec()); | 118 EXPECT_EQ(expected_url.GetOrigin().spec(), url.GetOrigin().spec()); |
| 121 EXPECT_EQ(expected_url.path(), url.path()); | 119 EXPECT_EQ(expected_url.path(), url.path()); |
| 122 } | 120 } |
| 123 | 121 |
| 124 } // namespace translate | 122 } // namespace translate |
| OLD | NEW |