OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 content::WindowedNotificationObserver language_observer1( | 1899 content::WindowedNotificationObserver language_observer1( |
1900 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 1900 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
1901 content::NotificationService::AllSources()); | 1901 content::NotificationService::AllSources()); |
1902 ui_test_utils::NavigateToURL(browser(), url); | 1902 ui_test_utils::NavigateToURL(browser(), url); |
1903 language_observer1.Wait(); | 1903 language_observer1.Wait(); |
1904 | 1904 |
1905 // Verify the translation detected for this tab. | 1905 // Verify the translation detected for this tab. |
1906 ChromeTranslateClient* chrome_translate_client = | 1906 ChromeTranslateClient* chrome_translate_client = |
1907 ChromeTranslateClient::FromWebContents(contents); | 1907 ChromeTranslateClient::FromWebContents(contents); |
1908 ASSERT_TRUE(chrome_translate_client); | 1908 ASSERT_TRUE(chrome_translate_client); |
1909 LanguageState& language_state = chrome_translate_client->GetLanguageState(); | 1909 translate::LanguageState& language_state = |
| 1910 chrome_translate_client->GetLanguageState(); |
1910 EXPECT_EQ("fr", language_state.original_language()); | 1911 EXPECT_EQ("fr", language_state.original_language()); |
1911 EXPECT_TRUE(language_state.page_needs_translation()); | 1912 EXPECT_TRUE(language_state.page_needs_translation()); |
1912 EXPECT_FALSE(language_state.translation_pending()); | 1913 EXPECT_FALSE(language_state.translation_pending()); |
1913 EXPECT_FALSE(language_state.translation_declined()); | 1914 EXPECT_FALSE(language_state.translation_declined()); |
1914 EXPECT_FALSE(language_state.IsPageTranslated()); | 1915 EXPECT_FALSE(language_state.IsPageTranslated()); |
1915 | 1916 |
1916 // Verify that the translate infobar showed up. | 1917 // Verify that the translate infobar showed up. |
1917 ASSERT_EQ(1u, infobar_service->infobar_count()); | 1918 ASSERT_EQ(1u, infobar_service->infobar_count()); |
1918 infobars::InfoBar* infobar = infobar_service->infobar_at(0); | 1919 infobars::InfoBar* infobar = infobar_service->infobar_at(0); |
1919 TranslateInfoBarDelegate* translate_infobar_delegate = | 1920 translate::TranslateInfoBarDelegate* translate_infobar_delegate = |
1920 infobar->delegate()->AsTranslateInfoBarDelegate(); | 1921 infobar->delegate()->AsTranslateInfoBarDelegate(); |
1921 ASSERT_TRUE(translate_infobar_delegate); | 1922 ASSERT_TRUE(translate_infobar_delegate); |
1922 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 1923 EXPECT_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
1923 translate_infobar_delegate->translate_step()); | 1924 translate_infobar_delegate->translate_step()); |
1924 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); | 1925 EXPECT_EQ("fr", translate_infobar_delegate->original_language_code()); |
1925 | 1926 |
1926 // Now force disable translate. | 1927 // Now force disable translate. |
1927 infobar_service->RemoveInfoBar(infobar); | 1928 infobar_service->RemoveInfoBar(infobar); |
1928 EXPECT_EQ(0u, infobar_service->infobar_count()); | 1929 EXPECT_EQ(0u, infobar_service->infobar_count()); |
1929 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, | 1930 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, |
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3037 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
3037 browser2->tab_strip_model()->GetActiveWebContents(), | 3038 browser2->tab_strip_model()->GetActiveWebContents(), |
3038 "domAutomationController.send(window.showModalDialog !== undefined);", | 3039 "domAutomationController.send(window.showModalDialog !== undefined);", |
3039 &result)); | 3040 &result)); |
3040 EXPECT_TRUE(result); | 3041 EXPECT_TRUE(result); |
3041 } | 3042 } |
3042 | 3043 |
3043 #endif // !defined(CHROME_OS) | 3044 #endif // !defined(CHROME_OS) |
3044 | 3045 |
3045 } // namespace policy | 3046 } // namespace policy |
OLD | NEW |