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

Unified Diff: chrome/browser/translate/translate_browsertest.cc

Issue 14180010: Translate: browser test for Chrome Translate in an isolated world (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for review Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/translate/translate_browsertest.cc
diff --git a/chrome/browser/translate/translate_browsertest.cc b/chrome/browser/translate/translate_browsertest.cc
index 4b04a09ff6a7c21aebcd5d0a919bb4d9dd1c624b..2f5a1553b432c2a9e7f1f405aa251b99ec7c800c 100644
--- a/chrome/browser/translate/translate_browsertest.cc
+++ b/chrome/browser/translate/translate_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -55,6 +56,13 @@ class TranslateBrowserTest : public InProcessBrowserTest {
ASSERT_TRUE(https_server_.Start());
}
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ // Setup altenate security-origin for testing.
+ GURL origin = GetSecureURL("");
+ command_line->AppendSwitchASCII(switches::kTranslateSecurityOrigin,
+ origin.spec());
+ }
+
protected:
GURL GetNonSecureURL(const std::string& path) const {
std::string prefix(kNonSecurePrefix);
@@ -74,9 +82,7 @@ class TranslateBrowserTest : public InProcessBrowserTest {
DISALLOW_COPY_AND_ASSIGN(TranslateBrowserTest);
};
-// TODO(toyoshim): This test should be changed to work in an isolated world.
-// See also http://crbug.com/164547 .
-IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, DISABLED_Translate) {
+IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, TranslateInIsolatedWorld) {
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (base::win::GetVersion() >= base::win::VERSION_WIN8)
@@ -95,7 +101,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, DISABLED_Translate) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
content::WindowedNotificationObserver infobar(
chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
content::NotificationService::AllSources());
@@ -111,9 +120,12 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, DISABLED_Translate) {
infobar.Wait();
// Perform Chrome Translate.
- ASSERT_EQ(1U, infobar_service->infobar_count());
+ ASSERT_EQ(2U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
+
TranslateInfoBarDelegate* translate =
- infobar_service->infobar_at(0)->AsTranslateInfoBarDelegate();
+ infobar_service->infobar_at(1)->AsTranslateInfoBarDelegate();
ASSERT_TRUE(translate);
translate->Translate();
@@ -167,7 +179,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
// Setup page title observer.
content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
@@ -183,7 +198,9 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTag) {
EXPECT_EQ("PASS", UTF16ToASCII(result));
// Check there is not infobar.
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
}
IN_PROC_BROWSER_TEST_F(TranslateBrowserTest,
@@ -204,7 +221,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest,
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
// Setup page title observer.
content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
@@ -220,7 +240,9 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest,
EXPECT_EQ("PASS", UTF16ToASCII(result));
// Check there is not infobar.
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
}
IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) {
@@ -240,7 +262,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
// Setup page title observer.
content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
@@ -256,7 +281,9 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, IgnoreRefreshMetaTagAtOnload) {
EXPECT_EQ("PASS", UTF16ToASCII(result));
// Check there is not infobar.
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
}
IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) {
@@ -276,7 +303,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
// Setup page title observer.
content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
@@ -292,7 +322,9 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocation) {
EXPECT_EQ("PASS", UTF16ToASCII(result));
// Check there is not infobar.
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
}
IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) {
@@ -312,7 +344,10 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) {
InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents);
ASSERT_TRUE(infobar_service);
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ ConfirmInfoBarDelegate* confirm =
+ infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
// Setup page title observer.
content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS"));
@@ -328,5 +363,7 @@ IN_PROC_BROWSER_TEST_F(TranslateBrowserTest, UpdateLocationAtOnload) {
EXPECT_EQ("PASS", UTF16ToASCII(result));
// Check there is not infobar.
- EXPECT_EQ(0U, infobar_service->infobar_count());
+ EXPECT_EQ(1U, infobar_service->infobar_count());
+ confirm = infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
+ EXPECT_TRUE(confirm);
}
« no previous file with comments | « no previous file | chrome/browser/ui/startup/bad_flags_prompt.cc » ('j') | chrome/test/data/translate/fr_test.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698