| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/translate/translate_script.h" | 5 #include "chrome/browser/translate/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 "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "components/translate/core/browser/translate_download_manager.h" |
| 11 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 12 #include "net/base/url_util.h" | 13 #include "net/base/url_util.h" |
| 13 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
| 14 #include "net/url_request/test_url_fetcher_factory.h" | 15 #include "net/url_request/test_url_fetcher_factory.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 class TranslateScriptTest : public testing::Test { | 19 class TranslateScriptTest : public testing::Test { |
| 19 public: | 20 public: |
| 20 TranslateScriptTest() : testing::Test() {} | 21 TranslateScriptTest() : testing::Test() {} |
| 21 | 22 |
| 22 protected: | 23 protected: |
| 23 virtual void SetUp() { | 24 virtual void SetUp() { |
| 24 script_.reset(new TranslateScript); | 25 script_.reset(new TranslateScript); |
| 25 DCHECK(script_.get()); | 26 DCHECK(script_.get()); |
| 27 TranslateDownloadManager::GetInstance()->set_application_locale("en"); |
| 26 } | 28 } |
| 27 | 29 |
| 28 virtual void TearDown() { | 30 virtual void TearDown() { |
| 29 script_.reset(); | 31 script_.reset(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void Request() { | 34 void Request() { |
| 33 script_->Request( | 35 script_->Request( |
| 34 base::Bind(&TranslateScriptTest::OnComplete, base::Unretained(this))); | 36 base::Bind(&TranslateScriptTest::OnComplete, base::Unretained(this))); |
| 35 } | 37 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 Request(); | 108 Request(); |
| 107 net::TestURLFetcher* fetcher = GetTestURLFetcher(); | 109 net::TestURLFetcher* fetcher = GetTestURLFetcher(); |
| 108 ASSERT_TRUE(fetcher); | 110 ASSERT_TRUE(fetcher); |
| 109 | 111 |
| 110 GURL expected_url(script_url); | 112 GURL expected_url(script_url); |
| 111 GURL url = fetcher->GetOriginalURL(); | 113 GURL url = fetcher->GetOriginalURL(); |
| 112 EXPECT_TRUE(url.is_valid()); | 114 EXPECT_TRUE(url.is_valid()); |
| 113 EXPECT_EQ(expected_url.GetOrigin().spec(), url.GetOrigin().spec()); | 115 EXPECT_EQ(expected_url.GetOrigin().spec(), url.GetOrigin().spec()); |
| 114 EXPECT_EQ(expected_url.path(), url.path()); | 116 EXPECT_EQ(expected_url.path(), url.path()); |
| 115 } | 117 } |
| OLD | NEW |