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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/translate/translate_infobar_delegate.h" | 11 #include "chrome/browser/translate/translate_infobar_delegate.h" |
12 #include "chrome/browser/translate/translate_script.h" | 12 #include "chrome/browser/translate/translate_script.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | |
16 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/test_switches.h" | 16 #include "chrome/test/base/test_switches.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
18 #include "components/translate/common/translate_switches.h" | |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
21 #include "net/http/http_status_code.h" | 21 #include "net/http/http_status_code.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
23 #include "net/test/spawned_test_server/spawned_test_server.h" | 23 #include "net/test/spawned_test_server/spawned_test_server.h" |
24 #include "net/url_request/test_url_fetcher_factory.h" | 24 #include "net/url_request/test_url_fetcher_factory.h" |
25 #include "net/url_request/url_fetcher_delegate.h" | 25 #include "net/url_request/url_fetcher_delegate.h" |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
(...skipping 20 matching lines...) Expand all Loading... | |
49 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, | 49 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, |
50 SSLOptions(SSLOptions::CERT_OK), | 50 SSLOptions(SSLOptions::CERT_OK), |
51 base::FilePath(kTranslateRoot)), | 51 base::FilePath(kTranslateRoot)), |
52 infobar_service_(NULL) {} | 52 infobar_service_(NULL) {} |
53 | 53 |
54 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 54 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
55 ASSERT_TRUE(https_server_.Start()); | 55 ASSERT_TRUE(https_server_.Start()); |
56 // Setup alternate security origin for testing in order to allow XHR against | 56 // Setup alternate security origin for testing in order to allow XHR against |
57 // local test server. Note that this flag shows a confirm infobar in tests. | 57 // local test server. Note that this flag shows a confirm infobar in tests. |
58 GURL base_url = GetSecureURL(""); | 58 GURL base_url = GetSecureURL(""); |
59 command_line->AppendSwitchASCII(switches::kTranslateSecurityOrigin, | 59 command_line->AppendSwitchASCII(translate::switches::kTranslateSecurityOrigi n, |
blundell
2013/10/02 11:02:22
Is this > 80 chars now?
droger
2013/10/02 11:09:12
Sorry, fixed.
| |
60 base_url.GetOrigin().spec()); | 60 base_url.GetOrigin().spec()); |
61 } | 61 } |
62 | 62 |
63 protected: | 63 protected: |
64 GURL GetNonSecureURL(const std::string& path) const { | 64 GURL GetNonSecureURL(const std::string& path) const { |
65 std::string prefix(kNonSecurePrefix); | 65 std::string prefix(kNonSecurePrefix); |
66 return embedded_test_server()->GetURL(prefix + path); | 66 return embedded_test_server()->GetURL(prefix + path); |
67 } | 67 } |
68 | 68 |
69 GURL GetSecureURL(const std::string& path) const { | 69 GURL GetSecureURL(const std::string& path) const { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 349 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
350 | 350 |
351 // Wait for the page title is changed after the test finished. | 351 // Wait for the page title is changed after the test finished. |
352 const string16 result = watcher.WaitAndGetTitle(); | 352 const string16 result = watcher.WaitAndGetTitle(); |
353 EXPECT_EQ("PASS", UTF16ToASCII(result)); | 353 EXPECT_EQ("PASS", UTF16ToASCII(result)); |
354 | 354 |
355 // Check if there is no Translate infobar. | 355 // Check if there is no Translate infobar. |
356 translate = GetExistingTranslateInfoBarDelegate(); | 356 translate = GetExistingTranslateInfoBarDelegate(); |
357 EXPECT_FALSE(translate); | 357 EXPECT_FALSE(translate); |
358 } | 358 } |
OLD | NEW |