diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 19:06:01 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 19:06:01 +0000 |
commit | 98b2864e2203979a4613ccff3cf7aa759af1da5b (patch) | |
tree | 65a6f843d18686b6e1b7f62442461c9a5ca7932a /chrome/browser/cocoa | |
parent | d387cf27ecfd94be6f39b1baf16ed4bd03a2b65a (diff) | |
download | chromium_src-98b2864e2203979a4613ccff3cf7aa759af1da5b.zip chromium_src-98b2864e2203979a4613ccff3cf7aa759af1da5b.tar.gz chromium_src-98b2864e2203979a4613ccff3cf7aa759af1da5b.tar.bz2 |
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
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/translate_infobar.mm | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/translate_infobar_unittest.mm | 12 |
2 files changed, 16 insertions, 3 deletions
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(); |