Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / autofill / generated_credit_card_bubble_controller_unittest.cc
index 42f9f50..d52aff5 100644 (file)
@@ -14,7 +14,7 @@
 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_view.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/test/base/testing_profile.h"
-#include "components/autofill/core/browser/autofill_common_test.h"
+#include "components/autofill/core/browser/autofill_test_utils.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/common/page_transition_types.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -31,11 +31,11 @@ namespace autofill {
 namespace {
 
 base::string16 BackingCard() {
-  return ASCIIToUTF16("Visa - 1111");
+  return base::ASCIIToUTF16("Visa - 1111");
 }
 
 base::string16 FrontingCard() {
-  return ASCIIToUTF16("Mastercard - 4444");
+  return base::ASCIIToUTF16("Mastercard - 4444");
 }
 
 base::string16 RangeOfString(const base::string16& string,
@@ -76,20 +76,12 @@ class GeneratedCreditCardBubbleControllerTest : public testing::Test {
                                                   BackingCard());
   }
 
-  void Navigate() {
-    NavigateWithTransition(content::PAGE_TRANSITION_LINK);
-  }
-
-  void Redirect() {
-    NavigateWithTransition(content::PAGE_TRANSITION_CLIENT_REDIRECT);
-  }
-
- private:
   void NavigateWithTransition(content::PageTransition trans) {
     content::WebContentsTester::For(test_web_contents_.get())->TestDidNavigate(
-        test_web_contents_->GetRenderViewHost(), 1, GURL("about:blank"), trans);
+        test_web_contents_->GetMainFrame(), 1, GURL("about:blank"), trans);
   }
 
+ private:
   content::TestBrowserThreadBundle thread_bundle_;
 #if defined(OS_WIN)
   // Without this there will be drag and drop failures. http://crbug.com/227221
@@ -158,24 +150,26 @@ TEST_F(GeneratedCreditCardBubbleControllerTest, AnchorIcon) {
   EXPECT_FALSE(controller()->AnchorIcon().IsEmpty());
 }
 
-TEST_F(GeneratedCreditCardBubbleControllerTest, HideOnNavigate) {
-  // When a user navigates away from a page (or refreshes) normally, the bubble
-  // should be hidden.
+TEST_F(GeneratedCreditCardBubbleControllerTest, HideOnLinkClick) {
   EXPECT_FALSE(controller()->GetTestingBubble());
   Show();
   EXPECT_TRUE(controller()->GetTestingBubble()->showing());
 
-  Navigate();
+  // However, if the user clicks a link the bubble should hide.
+  NavigateWithTransition(content::PAGE_TRANSITION_LINK);
   EXPECT_FALSE(controller());
 }
 
-TEST_F(GeneratedCreditCardBubbleControllerTest, StayOnRedirect) {
-  // If a page redirects right after submitting, the bubble should remain.
+TEST_F(GeneratedCreditCardBubbleControllerTest, StayOnSomeNavigations) {
   EXPECT_FALSE(controller()->GetTestingBubble());
   Show();
   EXPECT_TRUE(controller()->GetTestingBubble()->showing());
 
-  Redirect();
+  // If the user reloads or the page redirects or submits a form, the bubble
+  // should stay showing.
+  NavigateWithTransition(content::PAGE_TRANSITION_CLIENT_REDIRECT);
+  NavigateWithTransition(content::PAGE_TRANSITION_FORM_SUBMIT);
+  NavigateWithTransition(content::PAGE_TRANSITION_RELOAD);
   EXPECT_TRUE(controller()->GetTestingBubble()->showing());
 }