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