Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chrome/browser/translate/translate_browsertest.cc

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_manager.h"
11 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
12 #include "chrome/browser/translate/translate_infobar_delegate.h" 13 #include "chrome/browser/translate/translate_infobar_delegate.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"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 content::WebContents* web_contents = 84 content::WebContents* web_contents =
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
94 InfoBarManager& infobar_manager = infobar_service_->infobar_manager();
93 TranslateInfoBarDelegate* delegate = NULL; 95 TranslateInfoBarDelegate* delegate = NULL;
94 for (size_t i = 0; i < infobar_service_->infobar_count(); ++i) { 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 =
100 delegate()->AsConfirmInfoBarDelegate(); 102 infobar_manager.infobar_at(i)->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()
108 ->AsTranslateInfoBarDelegate();
106 if (translate) { 109 if (translate) {
107 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly"; 110 EXPECT_FALSE(delegate) << "multiple infobars are shown unexpectedly";
108 delegate = translate; 111 delegate = translate;
109 continue; 112 continue;
110 } 113 }
111 114
112 // Other infobar should not be shown. 115 // Other infobar should not be shown.
113 EXPECT_TRUE(delegate); 116 EXPECT_TRUE(delegate);
114 } 117 }
115 return delegate; 118 return delegate;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 GetNonSecureURL(kUpdateLocationAtOnloadTestPath)); 359 GetNonSecureURL(kUpdateLocationAtOnloadTestPath));
357 360
358 // Wait for the page title is changed after the test finished. 361 // Wait for the page title is changed after the test finished.
359 const base::string16 result = watcher.WaitAndGetTitle(); 362 const base::string16 result = watcher.WaitAndGetTitle();
360 EXPECT_EQ("PASS", base::UTF16ToASCII(result)); 363 EXPECT_EQ("PASS", base::UTF16ToASCII(result));
361 364
362 // Check if there is no Translate infobar. 365 // Check if there is no Translate infobar.
363 translate = GetExistingTranslateInfoBarDelegate(); 366 translate = GetExistingTranslateInfoBarDelegate();
364 EXPECT_FALSE(translate); 367 EXPECT_FALSE(translate);
365 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698