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.h" | 10 #include "chrome/browser/infobars/infobar.h" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/translate/translate_infobar_delegate.h" | 12 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 13 #include "chrome/browser/translate/translate_manager.h" |
13 #include "chrome/browser/translate/translate_service.h" | 14 #include "chrome/browser/translate/translate_service.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/test_switches.h" | 18 #include "chrome/test/base/test_switches.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
19 #include "components/translate/core/browser/translate_script.h" | 20 #include "components/translate/core/browser/translate_script.h" |
20 #include "components/translate/core/common/translate_switches.h" | 21 #include "components/translate/core/common/translate_switches.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 browser()->tab_strip_model()->GetActiveWebContents(); | 85 browser()->tab_strip_model()->GetActiveWebContents(); |
85 if (web_contents) | 86 if (web_contents) |
86 infobar_service_ = InfoBarService::FromWebContents(web_contents); | 87 infobar_service_ = InfoBarService::FromWebContents(web_contents); |
87 } | 88 } |
88 if (!infobar_service_) { | 89 if (!infobar_service_) { |
89 ADD_FAILURE() << "infobar service is not available"; | 90 ADD_FAILURE() << "infobar service is not available"; |
90 return NULL; | 91 return NULL; |
91 } | 92 } |
92 | 93 |
93 TranslateInfoBarDelegate* delegate = NULL; | 94 TranslateInfoBarDelegate* delegate = NULL; |
94 for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) { | 95 InfoBarManager* infobar_manager = infobar_service_->infobar_manager(); |
| 96 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { |
95 // Check if the shown infobar is a confirm infobar coming from the | 97 // Check if the shown infobar is a confirm infobar coming from the |
96 // |kTranslateSecurityOrigin| flag specified in SetUpCommandLine(). | 98 // |kTranslateSecurityOrigin| flag specified in SetUpCommandLine(). |
97 // This infobar appears in all tests of TranslateBrowserTest and can be | 99 // This infobar appears in all tests of TranslateBrowserTest and can be |
98 // ignored here. | 100 // ignored here. |
99 ConfirmInfoBarDelegate* confirm = infobar_service_->infobar_at(i)-> | 101 ConfirmInfoBarDelegate* confirm = infobar_manager->infobar_at(i) |
100 delegate()->AsConfirmInfoBarDelegate(); | 102 ->delegate()->AsConfirmInfoBarDelegate(); |
101 if (confirm) | 103 if (confirm) |
102 continue; | 104 continue; |
103 | 105 |
104 TranslateInfoBarDelegate* translate = infobar_service_->infobar_at(i)-> | 106 TranslateInfoBarDelegate* translate = infobar_manager->infobar_at(i) |
105 delegate()->AsTranslateInfoBarDelegate(); | 107 ->delegate()->AsTranslateInfoBarDelegate(); |
106 if (translate) { | 108 if (translate) { |
107 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; | 109 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; |
108 delegate = translate; | 110 delegate = translate; |
109 continue; | 111 continue; |
110 } | 112 } |
111 | 113 |
112 // Other infobar should not be shown. | 114 // Other infobar should not be shown. |
113 EXPECT_TRUE(delegate); | 115 EXPECT_TRUE(delegate); |
114 } | 116 } |
115 return delegate; | 117 return delegate; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 358 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
357 | 359 |
358 // Wait for the page title is changed after the test finished. | 360 // Wait for the page title is changed after the test finished. |
359 const base::string16 result = watcher.WaitAndGetTitle(); | 361 const base::string16 result = watcher.WaitAndGetTitle(); |
360 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 362 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
361 | 363 |
362 // Check if there is no Translate infobar. | 364 // Check if there is no Translate infobar. |
363 translate = GetExistingTranslateInfoBarDelegate(); | 365 translate = GetExistingTranslateInfoBarDelegate(); |
364 EXPECT_FALSE(translate); | 366 EXPECT_FALSE(translate); |
365 } | 367 } |
OLD | NEW |