Chromium Code Reviews| Index: chrome/browser/translate/translate_browsertest.cc |
| diff --git a/chrome/browser/translate/translate_browsertest.cc b/chrome/browser/translate/translate_browsertest.cc |
| index 93fe9b63f1a1d2453d54ab09cde9cfd3ca7a65c5..c7c9e0bf0dd780b0d009080055d0de76569535bd 100644 |
| --- a/chrome/browser/translate/translate_browsertest.cc |
| +++ b/chrome/browser/translate/translate_browsertest.cc |
| @@ -49,8 +49,12 @@ class TranslateBrowserTest : public InProcessBrowserTest { |
| SSLOptions(SSLOptions::CERT_OK), |
| base::FilePath(kTranslateRoot)) {} |
| - virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| ASSERT_TRUE(https_server_.Start()); |
| + // Setup altenate security-origin for testing. |
| + GURL origin = GetSecureURL(""); |
| + command_line->AppendSwitchASCII(switches::kTranslateSecurityOrigin, |
| + origin.spec()); |
| } |
| protected: |
| @@ -72,9 +76,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 (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| @@ -93,7 +95,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); |
|
hajimehoshi
2013/07/31 06:59:23
Please add comment to explain why the confirm info
|
| content::WindowedNotificationObserver infobar( |
| chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| content::NotificationService::AllSources()); |
| @@ -109,9 +114,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(); |
| @@ -165,7 +173,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")); |
| @@ -181,7 +192,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, |
| @@ -202,7 +215,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); |
|
hajimehoshi
2013/07/31 07:04:01
ditto
|
| // Setup page title observer. |
| content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
| @@ -218,7 +234,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) { |
| @@ -238,7 +256,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); |
|
hajimehoshi
2013/07/31 07:04:01
ditto
|
| // Setup page title observer. |
| content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
| @@ -254,7 +275,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) { |
| @@ -274,7 +297,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); |
|
hajimehoshi
2013/07/31 07:04:01
ditto
|
| // Setup page title observer. |
| content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
| @@ -290,7 +316,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) { |
| @@ -310,7 +338,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); |
|
hajimehoshi
2013/07/31 07:04:01
ditto
|
| // Setup page title observer. |
| content::TitleWatcher watcher(web_contents, ASCIIToUTF16("PASS")); |
| @@ -326,5 +357,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); |
| } |