From 98b2864e2203979a4613ccff3cf7aa759af1da5b Mon Sep 17 00:00:00 2001 From: "jeremy@chromium.org" Date: Tue, 13 Apr 2010 19:06:01 +0000 Subject: Make the "Try again" button in the translate infobar not trigger a DCHECK . Loosen up a DCHECK and add a unit test. BUG=41315 TEST=Repro steps in Bug. Review URL: http://codereview.chromium.org/1525030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44379 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/cocoa/translate_infobar.mm | 7 ++++--- chrome/browser/cocoa/translate_infobar_unittest.mm | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'chrome/browser/cocoa') diff --git a/chrome/browser/cocoa/translate_infobar.mm b/chrome/browser/cocoa/translate_infobar.mm index 6cb3169..412e535 100644 --- a/chrome/browser/cocoa/translate_infobar.mm +++ b/chrome/browser/cocoa/translate_infobar.mm @@ -619,10 +619,11 @@ class TranslateNotificationObserverBridge : // Called when "Translate" button is clicked. - (IBAction)ok:(id)sender { TranslateInfoBarDelegate* delegate = [self delegate]; - DCHECK( - delegate->state() == TranslateInfoBarDelegate::kBeforeTranslate); + TranslateInfoBarDelegate::TranslateState state = delegate->state(); + DCHECK(state == TranslateInfoBarDelegate::kBeforeTranslate || + state == TranslateInfoBarDelegate::kTranslateError); delegate->Translate(); - [self updateState:delegate->state() + [self updateState:state translationPending:delegate->translation_pending() error:delegate->error_type()]; UMA_HISTOGRAM_COUNTS("Translate.Translate", 1); diff --git a/chrome/browser/cocoa/translate_infobar_unittest.mm b/chrome/browser/cocoa/translate_infobar_unittest.mm index 4f5d639..07e4185 100644 --- a/chrome/browser/cocoa/translate_infobar_unittest.mm +++ b/chrome/browser/cocoa/translate_infobar_unittest.mm @@ -96,6 +96,18 @@ TEST_F(TranslationBarInfoTest, TranslateCalledOnButtonPress) { [infobar_controller ok:nil]; } +// Check that clicking the "Retry" button calls Translate() when we're +// in the error mode - http://crbug.com/41315 . +TEST_F(TranslationBarInfoTest, TranslateCalledInErrorMode) { + CreateInfoBar(); + + EXPECT_CALL(*infobar_delegate, Translate()).Times(1); + + infobar_delegate->UpdateState(TranslateInfoBarDelegate::kTranslateError, + TranslateErrors::NONE); + [infobar_controller ok:nil]; +} + // Check that clicking the "Show Original button calls RevertTranslation(). TEST_F(TranslationBarInfoTest, RevertCalledOnButtonPress) { CreateInfoBar(); -- cgit v1.1