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" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 browser()->tab_strip_model()->GetActiveWebContents(); | 85 browser()->tab_strip_model()->GetActiveWebContents(); |
86 if (web_contents) | 86 if (web_contents) |
87 infobar_service_ = InfoBarService::FromWebContents(web_contents); | 87 infobar_service_ = InfoBarService::FromWebContents(web_contents); |
88 } | 88 } |
89 if (!infobar_service_) { | 89 if (!infobar_service_) { |
90 ADD_FAILURE() << "infobar service is not available"; | 90 ADD_FAILURE() << "infobar service is not available"; |
91 return NULL; | 91 return NULL; |
92 } | 92 } |
93 | 93 |
94 TranslateInfoBarDelegate* delegate = NULL; | 94 TranslateInfoBarDelegate* delegate = NULL; |
95 InfoBarManager* infobar_manager = infobar_service_->infobar_manager(); | 95 for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) { |
96 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { | |
97 // Check if the shown infobar is a confirm infobar coming from the | 96 // Check if the shown infobar is a confirm infobar coming from the |
98 // |kTranslateSecurityOrigin| flag specified in SetUpCommandLine(). | 97 // |kTranslateSecurityOrigin| flag specified in SetUpCommandLine(). |
99 // This infobar appears in all tests of TranslateBrowserTest and can be | 98 // This infobar appears in all tests of TranslateBrowserTest and can be |
100 // ignored here. | 99 // ignored here. |
101 ConfirmInfoBarDelegate* confirm = infobar_manager->infobar_at(i) | 100 if (infobar_service_->infobar_at(i)->delegate()-> |
102 ->delegate()->AsConfirmInfoBarDelegate(); | 101 AsConfirmInfoBarDelegate()) { |
103 if (confirm) | |
104 continue; | 102 continue; |
| 103 } |
105 | 104 |
106 TranslateInfoBarDelegate* translate = infobar_manager->infobar_at(i) | 105 TranslateInfoBarDelegate* translate = |
107 ->delegate()->AsTranslateInfoBarDelegate(); | 106 infobar_service_->infobar_at(i)->delegate()-> |
| 107 AsTranslateInfoBarDelegate(); |
108 if (translate) { | 108 if (translate) { |
109 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; | 109 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; |
110 delegate = translate; | 110 delegate = translate; |
111 continue; | 111 continue; |
112 } | 112 } |
113 | 113 |
114 // Other infobar should not be shown. | 114 // Other infobar should not be shown. |
115 EXPECT_TRUE(delegate); | 115 EXPECT_TRUE(delegate); |
116 } | 116 } |
117 return delegate; | 117 return delegate; |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 358 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
359 | 359 |
360 // Wait for the page title is changed after the test finished. | 360 // Wait for the page title is changed after the test finished. |
361 const base::string16 result = watcher.WaitAndGetTitle(); | 361 const base::string16 result = watcher.WaitAndGetTitle(); |
362 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 362 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
363 | 363 |
364 // Check if there is no Translate infobar. | 364 // Check if there is no Translate infobar. |
365 translate = GetExistingTranslateInfoBarDelegate(); | 365 translate = GetExistingTranslateInfoBarDelegate(); |
366 EXPECT_FALSE(translate); | 366 EXPECT_FALSE(translate); |
367 } | 367 } |
OLD | NEW |