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

Side by Side Diff: chrome/browser/autofill/autofill_browsertest.cc

Issue 10830353: Introduce InfoBarTabService API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments, merge to LKGR Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autofill/DEPS ('k') | chrome/browser/autofill/autofill_cc_infobar_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/api/infobars/infobar_tab_service.h"
12 #include "chrome/browser/autofill/autofill_common_test.h" 13 #include "chrome/browser/autofill/autofill_common_test.h"
13 #include "chrome/browser/autofill/autofill_profile.h" 14 #include "chrome/browser/autofill/autofill_profile.h"
14 #include "chrome/browser/autofill/personal_data_manager.h" 15 #include "chrome/browser/autofill/personal_data_manager.h"
15 #include "chrome/browser/autofill/personal_data_manager_factory.h" 16 #include "chrome/browser/autofill/personal_data_manager_factory.h"
16 #include "chrome/browser/autofill/personal_data_manager_observer.h" 17 #include "chrome/browser/autofill/personal_data_manager_observer.h"
17 #include "chrome/browser/infobars/infobar_tab_helper.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/translate/translate_infobar_delegate.h" 19 #include "chrome/browser/translate/translate_infobar_delegate.h"
20 #include "chrome/browser/translate/translate_manager.h" 20 #include "chrome/browser/translate/translate_manager.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tab_contents/tab_contents.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents.h"
25 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/render_messages.h" 26 #include "chrome/common/render_messages.h"
27 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 " <input type=\"text\" id=\"ph\"><br>" 671 " <input type=\"text\" id=\"ph\"><br>"
672 "</form>"); 672 "</form>");
673 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 673 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
674 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); 674 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url));
675 675
676 // Get translation bar. 676 // Get translation bar.
677 RenderViewHostTester::TestOnMessageReceived( 677 RenderViewHostTester::TestOnMessageReceived(
678 render_view_host(), 678 render_view_host(),
679 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); 679 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true));
680 TranslateInfoBarDelegate* infobar = 680 TranslateInfoBarDelegate* infobar =
681 chrome::GetActiveTabContents(browser())->infobar_tab_helper()-> 681 InfoBarTabService::ForTab(chrome::GetActiveTabContents(browser()))->
682 GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); 682 GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate();
683 683
684 ASSERT_TRUE(infobar != NULL); 684 ASSERT_TRUE(infobar != NULL);
685 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); 685 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type());
686 686
687 // Simulate translation button press. 687 // Simulate translation button press.
688 infobar->Translate(); 688 infobar->Translate();
689 689
690 // Simulate the translate script being retrieved. 690 // Simulate the translate script being retrieved.
691 // Pass fake google.translate lib as the translate script. 691 // Pass fake google.translate lib as the translate script.
692 SimulateURLFetch(true); 692 SimulateURLFetch(true);
693 693
694 content::WindowedNotificationObserver translation_observer( 694 content::WindowedNotificationObserver translation_observer(
695 chrome::NOTIFICATION_PAGE_TRANSLATED, 695 chrome::NOTIFICATION_PAGE_TRANSLATED,
696 content::NotificationService::AllSources()); 696 content::NotificationService::AllSources());
697 697
698 // Simulate translation to kick onTranslateElementLoad. 698 // Simulate translation to kick onTranslateElementLoad.
699 // But right now, the call stucks here. 699 // But right now, the call stucks here.
700 // Once click the text field, it starts again. 700 // Once click the text field, it starts again.
701 ASSERT_TRUE(content::ExecuteJavaScript( 701 ASSERT_TRUE(content::ExecuteJavaScript(
702 render_view_host(), L"", 702 render_view_host(), L"",
703 L"cr.googleTranslate.onTranslateElementLoad();")); 703 L"cr.googleTranslate.onTranslateElementLoad();"));
704 704
705 // Simulate the render notifying the translation has been done. 705 // Simulate the render notifying the translation has been done.
706 translation_observer.Wait(); 706 translation_observer.Wait();
707 707
708 TryBasicFormFill(); 708 TryBasicFormFill();
709 } 709 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/DEPS ('k') | chrome/browser/autofill/autofill_cc_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698