diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 16:41:53 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 16:41:53 +0000 |
commit | 8db841ac0528a7eba71e89260526da9ba33dbb54 (patch) | |
tree | 79501d52aa828b2bbaf87e91064f978851d702d2 /chrome/browser/translate/translate_manager_unittest.cc | |
parent | 89e29d25efa776ed1f564e576d764fd3e9ddecfc (diff) | |
download | chromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.zip chromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.tar.gz chromium_src-8db841ac0528a7eba71e89260526da9ba33dbb54.tar.bz2 |
implement error state for translate infobar
- this cl implements the UI on Windows and the partial backend of IPC messaging to include error type
- implement error state
- add translate error types
- use a structure as details for IPC messaging between render view and browser so as to include error type (was using std::pair)
- translate delegate handles error state and provides mapping to error messages
- infobar handles visual error states
- modify background painting to handle normal and error backgrounds, and animation of cross-fading between the 2 backgrounds
- infobar now stores state (and translation_pending flag) that it's currently displaying to user, instead of just relying on TransateInfoBarDelegate's
- if infobar receives PAGE_TRANSLAED notification before delegate does (possible because order is not fixed), delegate's state won't be updated to be used by infobar.
- after all the observers have received the notification, both infobar and delegate will end up with matching states, so there's no worries of out-of-sync.
- update unittests accordingly
- update mac and linux code accordingly to make build pass
- jay will implement the remaining backend to pass actual translate error types to the IPC message (tracked by bug 37778)
BUG=38548
TEST=none yet, until bug 37778 is also fixed.
Review URL: http://codereview.chromium.org/1321003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate/translate_manager_unittest.cc')
-rw-r--r-- | chrome/browser/translate/translate_manager_unittest.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc index 30bc4c5..0a982fd 100644 --- a/chrome/browser/translate/translate_manager_unittest.cc +++ b/chrome/browser/translate/translate_manager_unittest.cc @@ -268,7 +268,8 @@ TEST_F(TranslateManagerTest, NormalTranslate) { // EXPECT_EQ(TranslateInfoBarDelegate::kTranslating, infobar->state()); // Simulate the render notifying the translation has been done. - rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en")); + rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", + TranslateErrors::NONE)); // The infobar should have changed to the after state. EXPECT_FALSE(InfoBarRemoved()); @@ -375,7 +376,8 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) { TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); ASSERT_TRUE(infobar != NULL); infobar->Translate(); - rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en")); + rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", + TranslateErrors::NONE)); // Now navigate to a new page in the same language. process()->sink().ClearMessages(); @@ -517,7 +519,8 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) { TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); ASSERT_TRUE(infobar != NULL); infobar->Translate(); - rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en")); + rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", + TranslateErrors::NONE)); // Close the infobar. EXPECT_TRUE(CloseTranslateInfoBar()); @@ -544,7 +547,8 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) { TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); ASSERT_TRUE(infobar != NULL); infobar->Translate(); - rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en")); + rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", + TranslateErrors::NONE)); // Navigate in page, the same infobar should still be shown. SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, L"Le Google", "fr"); @@ -767,7 +771,8 @@ TEST_F(TranslateManagerTest, ContextMenu) { process()->sink().ClearMessages(); // Let's simulate the page being translated. - rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en")); + rvh()->TestOnMessageReceived(ViewHostMsg_PageTranslated(0, 0, "fr", "en", + TranslateErrors::NONE)); // The translate menu should now be disabled. menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents())); |