diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 05:00:10 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-18 05:00:10 +0000 |
commit | 9966325b7197accb38248ebf48983bf0d06c525b (patch) | |
tree | b33fb7ebf51ae47074e5db5c7f255ffd7c9e75f9 /chrome/renderer/translate_helper_browsertest.cc | |
parent | 9db98a2b1c29c70dc1a2a8a9d5169c7c5411297c (diff) | |
download | chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.zip chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.tar.gz chromium_src-9966325b7197accb38248ebf48983bf0d06c525b.tar.bz2 |
Remove the last Chrome dependencies from renderer, and enforce no more includes through DEPS. I also added DEPS checking for gpu/plugin/worker directories as well. I moved the Chrome specific browser tests to the chrome directory, and removed render_widget_unittest since it didn't seem to be testing much (there are tests that test it much more fully). I had to move bindings_policy.h, which ideally would be split into separate pieces so that the content layer only has to know about the content bindings. Given that it's basically an enum, I moved the whole file now since it's used in a lot of places, and the value of turning on DEPS checking is really high.
Review URL: http://codereview.chromium.org/6874038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/translate_helper_browsertest.cc')
-rw-r--r-- | chrome/renderer/translate_helper_browsertest.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/renderer/translate_helper_browsertest.cc b/chrome/renderer/translate_helper_browsertest.cc index 9298305..e375148 100644 --- a/chrome/renderer/translate_helper_browsertest.cc +++ b/chrome/renderer/translate_helper_browsertest.cc @@ -293,3 +293,72 @@ TEST_F(TranslateHelperTest, MultipleDifferentTranslations) { EXPECT_EQ(new_target_lang, received_target_lang); EXPECT_EQ(TranslateErrors::NONE, error); } + +// Tests that we send the right translatable for a page and that we respect the +// "no translate" meta-tag. +TEST_F(RenderViewTest, TranslatablePage) { + // Suppress the normal delay that occurs when the page is loaded before which + // the renderer sends the page contents to the browser. + view_->set_send_content_state_immediately(true); + + LoadHTML("<html><body>A random page with random content.</body></html>"); + ProcessPendingMessages(); + const IPC::Message* message = render_thread_.sink().GetUniqueMessageMatching( + ViewHostMsg_TranslateLanguageDetermined::ID); + ASSERT_NE(static_cast<IPC::Message*>(NULL), message); + ViewHostMsg_TranslateLanguageDetermined::Param params; + ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); + EXPECT_TRUE(params.b); // Translatable should be true. + render_thread_.sink().ClearMessages(); + + // Now the page specifies the META tag to prevent translation. + LoadHTML("<html><head><meta name=\"google\" value=\"notranslate\"></head>" + "<body>A random page with random content.</body></html>"); + ProcessPendingMessages(); + message = render_thread_.sink().GetUniqueMessageMatching( + ViewHostMsg_TranslateLanguageDetermined::ID); + ASSERT_NE(static_cast<IPC::Message*>(NULL), message); + ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); + EXPECT_FALSE(params.b); // Translatable should be false. + render_thread_.sink().ClearMessages(); + + // Try the alternate version of the META tag (content instead of value). + LoadHTML("<html><head><meta name=\"google\" content=\"notranslate\"></head>" + "<body>A random page with random content.</body></html>"); + ProcessPendingMessages(); + message = render_thread_.sink().GetUniqueMessageMatching( + ViewHostMsg_TranslateLanguageDetermined::ID); + ASSERT_NE(static_cast<IPC::Message*>(NULL), message); + ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); + EXPECT_FALSE(params.b); // Translatable should be false. +} + +// Tests that the language meta tag takes precedence over the CLD when reporting +// the page's language. +TEST_F(RenderViewTest, LanguageMetaTag) { + // Suppress the normal delay that occurs when the page is loaded before which + // the renderer sends the page contents to the browser. + view_->set_send_content_state_immediately(true); + + LoadHTML("<html><head><meta http-equiv=\"content-language\" content=\"es\">" + "</head><body>A random page with random content.</body></html>"); + ProcessPendingMessages(); + const IPC::Message* message = render_thread_.sink().GetUniqueMessageMatching( + ViewHostMsg_TranslateLanguageDetermined::ID); + ASSERT_NE(static_cast<IPC::Message*>(NULL), message); + ViewHostMsg_TranslateLanguageDetermined::Param params; + ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); + EXPECT_EQ("es", params.a); + render_thread_.sink().ClearMessages(); + + // Makes sure we support multiple languages specified. + LoadHTML("<html><head><meta http-equiv=\"content-language\" " + "content=\" fr , es,en \">" + "</head><body>A random page with random content.</body></html>"); + ProcessPendingMessages(); + message = render_thread_.sink().GetUniqueMessageMatching( + ViewHostMsg_TranslateLanguageDetermined::ID); + ASSERT_NE(static_cast<IPC::Message*>(NULL), message); + ViewHostMsg_TranslateLanguageDetermined::Read(message, ¶ms); + EXPECT_EQ("fr", params.a); +} |