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

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

Issue 2822032: TranslateInfoBarDelegate2 were leaked. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fixed unit-test Created 10 years, 6 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
« no previous file with comments | « chrome/browser/translate/translate_infobar_delegate2.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/translate/translate_manager2_unittest.cc
diff --git a/chrome/browser/translate/translate_manager2_unittest.cc b/chrome/browser/translate/translate_manager2_unittest.cc
index 5f171e20bd0c5b547b6052fefae9a880becc3670..1f55723d57f6983b9e80ab5a6316353642075d26 100644
--- a/chrome/browser/translate/translate_manager2_unittest.cc
+++ b/chrome/browser/translate/translate_manager2_unittest.cc
@@ -303,19 +303,38 @@ TEST_F(TranslateManager2Test, NormalTranslate) {
ASSERT_TRUE(infobar != NULL);
EXPECT_EQ(TranslateInfoBarDelegate2::AFTER_TRANSLATE, infobar->type());
- // Simulate translating again from there but with 2 different languages.
+ // Simulate changing the original language, this should trigger a translation.
+ process()->sink().ClearMessages();
+ std::string new_original_lang = infobar->GetLanguageCodeAt(0);
infobar->SetOriginalLanguage(0);
- infobar->SetTargetLanguage(1);
- std::string new_original_lang = infobar->GetOriginalLanguageCode();
- std::string new_target_lang = infobar->GetTargetLanguageCode();
+ EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
+ EXPECT_EQ(0, page_id);
+ EXPECT_EQ(new_original_lang, original_lang);
+ EXPECT_EQ("en", target_lang);
+ // Simulate the render notifying the translation has been done.
+ rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0,
+ new_original_lang, "en", TranslateErrors::NONE));
+ // infobar is now invalid.
+ TranslateInfoBarDelegate2* new_infobar = GetTranslateInfoBar();
+ ASSERT_TRUE(new_infobar != NULL);
+ EXPECT_NE(infobar, new_infobar);
+ infobar = new_infobar;
+
+ // Simulate changing the target language, this should trigger a translation.
process()->sink().ClearMessages();
- infobar->Translate();
-
- // Test that we sent the right message to the renderer.
+ std::string new_target_lang = infobar->GetLanguageCodeAt(1);
+ infobar->SetTargetLanguage(1);
EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_EQ(0, page_id);
EXPECT_EQ(new_original_lang, original_lang);
EXPECT_EQ(new_target_lang, target_lang);
+ // Simulate the render notifying the translation has been done.
+ rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0,
+ new_original_lang, new_target_lang, TranslateErrors::NONE));
+ // infobar is now invalid.
+ new_infobar = GetTranslateInfoBar();
+ ASSERT_TRUE(new_infobar != NULL);
+ EXPECT_NE(infobar, new_infobar);
}
TEST_F(TranslateManager2Test, TranslateScriptNotAvailable) {
« no previous file with comments | « chrome/browser/translate/translate_infobar_delegate2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698