OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 3011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3022 ASSERT_EQ(4ul, renders.size()); | 3022 ASSERT_EQ(4ul, renders.size()); |
3023 for (size_t i = 0; i < renders.size(); ++i) { | 3023 for (size_t i = 0; i < renders.size(); ++i) { |
3024 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3024 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
3025 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3025 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
3026 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3026 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
3027 double docDuration = docFinishTime - docStartTime; | 3027 double docDuration = docFinishTime - docStartTime; |
3028 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3028 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
3029 } | 3029 } |
3030 } | 3030 } |
3031 | 3031 |
3032 TEST_F(WebViewTest, MoveFocusToNextFocusableElementInForm) | |
3033 { | |
3034 const std::string testFile = "advance_focus_in_form.html"; | |
3035 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8(testFile.c_str())); | |
3036 WebView* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + testFil e, true, 0); | |
3037 webViewImpl->setInitialFocus(false); | |
3038 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | |
3039 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | |
3040 const int defaultTextInputFlags = WebTextInputFlagAutocapitalizeSentences; | |
3041 | |
3042 // Forward Navigation in form1 with NEXT | |
3043 Element* input1 = document->getElementById("input1"); | |
3044 input1->focus(); | |
3045 WebTextInputInfo textInputInfo = webViewImpl->textInputInfo(); | |
3046 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement, textInputInfo.flags); | |
3047 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3048 | |
3049 Element* contenteditable1 = document->getElementById("contenteditable1"); | |
3050 EXPECT_EQ(contenteditable1, document->focusedElement()); | |
3051 textInputInfo = webViewImpl->textInputInfo(); | |
3052 EXPECT_EQ(WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePre viousFocusableElement, textInputInfo.flags); | |
3053 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3054 | |
3055 Element* input2 = document->getElementById("input2"); | |
3056 EXPECT_EQ(input2, document->focusedElement()); | |
3057 textInputInfo = webViewImpl->textInputInfo(); | |
3058 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement | WebTextInputFlagListeningToKeybo ardEvents, textInputInfo.flags); | |
3059 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3060 | |
3061 Element* textarea1 = document->getElementById("textarea1"); | |
3062 EXPECT_EQ(textarea1, document->focusedElement()); | |
3063 textInputInfo = webViewImpl->textInputInfo(); | |
3064 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
3065 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3066 | |
3067 Element* input3 = document->getElementById("input3"); | |
3068 EXPECT_EQ(input3, document->focusedElement()); | |
3069 textInputInfo = webViewImpl->textInputInfo(); | |
3070 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
3071 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3072 | |
3073 Element* textarea2 = document->getElementById("textarea2"); | |
3074 EXPECT_EQ(textarea2, document->focusedElement()); | |
3075 textInputInfo = webViewImpl->textInputInfo(); | |
3076 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHavePreviousFocusableEleme nt, textInputInfo.flags); | |
3077 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3078 // No next element, hence focus will stay on same element. | |
3079 EXPECT_EQ(textarea2, document->focusedElement()); | |
3080 | |
3081 // Backward Navigation in form1 with PREVIOUS | |
3082 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3083 EXPECT_EQ(input3, document->focusedElement()); | |
3084 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3085 EXPECT_EQ(textarea1, document->focusedElement()); | |
3086 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3087 EXPECT_EQ(input2, document->focusedElement()); | |
3088 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3089 EXPECT_EQ(contenteditable1, document->focusedElement()); | |
3090 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3091 EXPECT_EQ(input1, document->focusedElement()); | |
3092 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3093 // No previous element, hence focus will stay on same element. | |
3094 EXPECT_EQ(input1, document->focusedElement()); | |
3095 | |
3096 // Navigation of elements which is not part of any forms. | |
3097 Element* contenteditable2 = document->getElementById("contenteditable2"); | |
3098 document->setFocusedElement(contenteditable2); | |
3099 textInputInfo = webViewImpl->textInputInfo(); | |
3100 // No Next/Previous element for elements outside form. | |
3101 EXPECT_NE(WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePre viousFocusableElement, textInputInfo.flags); | |
3102 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3103 // No Next/Previous element to this element because it's not part of any for m. Hence focus won't change wrt NEXT/PREVIOS. | |
kochi
2015/07/28 08:43:02
nit: s/PREVIOS/PREVIOUS/
AKV
2015/08/05 08:55:55
Done.
| |
3104 EXPECT_EQ(contenteditable2, document->focusedElement()); | |
3105 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3106 EXPECT_EQ(contenteditable2, document->focusedElement()); | |
3107 | |
3108 Element* textarea3 = document->getElementById("textarea3"); | |
3109 textarea3->focus(); | |
3110 textInputInfo = webViewImpl->textInputInfo(); | |
3111 // No Next/Previous element for elements outside form. | |
3112 EXPECT_NE(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
3113 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3114 // No Next/Previous element to this element because it's not part of any for m. Hence focus won't change wrt NEXT/PREVIOS. | |
kochi
2015/07/28 08:43:02
nit: s/PREVIOS/PREVIOUS/
AKV
2015/08/05 08:55:55
Done.
| |
3115 EXPECT_EQ(textarea3, document->focusedElement()); | |
3116 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3117 EXPECT_EQ(textarea3, document->focusedElement()); | |
3118 | |
3119 // Navigation of elements which is having invalid form attribute and hence n ot part of any forms. | |
3120 Element* textarea4 = document->getElementById("textarea4"); | |
3121 textarea4->focus(); | |
3122 textInputInfo = webViewImpl->textInputInfo(); | |
3123 // No Next/Previous element for elements outside form. | |
3124 EXPECT_NE(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
3125 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3126 // No Next/Previous element to this element because it's not part of any for m. Hence focus won't change wrt NEXT/PREVIOS. | |
kochi
2015/07/28 08:43:03
nit: s/PREVIOS/PREVIOUS/
AKV
2015/08/05 08:55:55
Done.
| |
3127 EXPECT_EQ(textarea4, document->focusedElement()); | |
3128 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3129 EXPECT_EQ(textarea4, document->focusedElement()); | |
3130 | |
3131 // Forward Navigation in form2 with NEXT | |
3132 Element* textarea5 = document->getElementById("textarea5"); | |
3133 textarea5->focus(); | |
3134 textInputInfo = webViewImpl->textInputInfo(); | |
3135 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHaveNextFocusableElement, textInputInfo.flags); | |
3136 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3137 | |
3138 Element* input4 = document->getElementById("input4"); | |
3139 EXPECT_EQ(input4, document->focusedElement()); | |
3140 textInputInfo = webViewImpl->textInputInfo(); | |
3141 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusab leElement, textInputInfo.flags); | |
3142 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3143 | |
3144 Element* contenteditable3 = document->getElementById("contenteditable3"); | |
3145 EXPECT_EQ(contenteditable3, document->focusedElement()); | |
3146 textInputInfo = webViewImpl->textInputInfo(); | |
3147 EXPECT_EQ(WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHavePr eviousFocusableElement, textInputInfo.flags); | |
3148 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
3149 // No next element, hence focus will stay on same element. | |
3150 EXPECT_EQ(contenteditable3, document->focusedElement()); | |
3151 | |
3152 // Backward Navigation in form2 with PREVIOUS | |
3153 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3154 EXPECT_EQ(input4, document->focusedElement()); | |
3155 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3156 EXPECT_EQ(textarea5, document->focusedElement()); | |
3157 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
3158 // No previous element, hence focus will stay on same element. | |
3159 EXPECT_EQ(textarea5, document->focusedElement()); | |
3160 | |
3161 m_webViewHelper.reset(); | |
3162 } | |
3163 | |
3032 } // namespace blink | 3164 } // namespace blink |
OLD | NEW |