Chromium Code Reviews| 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 ConfirmInfoBarDelegate* confirm = infobar_service_->infobar_at(i) |
| 102 ->delegate()->AsConfirmInfoBarDelegate(); | 101 ->delegate() |
| 102 ->AsConfirmInfoBarDelegate(); | |
|
Peter Kasting
2014/04/10 00:08:59
Nit: I'd condense/wrap like this:
if (infob
| |
| 103 if (confirm) | 103 if (confirm) |
| 104 continue; | 104 continue; |
| 105 | 105 |
| 106 TranslateInfoBarDelegate* translate = infobar_manager->infobar_at(i) | 106 TranslateInfoBarDelegate* translate = infobar_service_->infobar_at(i) |
| 107 ->delegate()->AsTranslateInfoBarDelegate(); | 107 ->delegate() |
| 108 ->AsTranslateInfoBarDelegate(); | |
| 108 if (translate) { | 109 if (translate) { |
| 109 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; | 110 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; |
| 110 delegate = translate; | 111 delegate = translate; |
| 111 continue; | 112 continue; |
| 112 } | 113 } |
| 113 | 114 |
| 114 // Other infobar should not be shown. | 115 // Other infobar should not be shown. |
| 115 EXPECT_TRUE(delegate); | 116 EXPECT_TRUE(delegate); |
| 116 } | 117 } |
| 117 return delegate; | 118 return delegate; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); | 359 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); |
| 359 | 360 |
| 360 // Wait for the page title is changed after the test finished. | 361 // Wait for the page title is changed after the test finished. |
| 361 const base::string16 result = watcher.WaitAndGetTitle(); | 362 const base::string16 result = watcher.WaitAndGetTitle(); |
| 362 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); | 363 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); |
| 363 | 364 |
| 364 // Check if there is no Translate infobar. | 365 // Check if there is no Translate infobar. |
| 365 translate = GetExistingTranslateInfoBarDelegate(); | 366 translate = GetExistingTranslateInfoBarDelegate(); |
| 366 EXPECT_FALSE(translate); | 367 EXPECT_FALSE(translate); |
| 367 } | 368 } |
| OLD | NEW |