Chromium Code Reviews| 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 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3042 ASSERT_EQ(4ul, renders.size()); | 3042 ASSERT_EQ(4ul, renders.size()); |
| 3043 for (size_t i = 0; i < renders.size(); ++i) { | 3043 for (size_t i = 0; i < renders.size(); ++i) { |
| 3044 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3044 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
| 3045 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3045 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
| 3046 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3046 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
| 3047 double docDuration = docFinishTime - docStartTime; | 3047 double docDuration = docFinishTime - docStartTime; |
| 3048 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3048 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
| 3049 } | 3049 } |
| 3050 } | 3050 } |
| 3051 | 3051 |
| 3052 TEST_F(WebViewTest, MoveFocusToNextFocusableElementInForm) | |
| 3053 { | |
| 3054 const std::string testFile = "advance-focus-in-form.html"; | |
| 3055 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8(testFile.c_str())); | |
| 3056 WebView* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + testFil e, true, 0); | |
| 3057 webViewImpl->setInitialFocus(false); | |
| 3058 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webViewImpl->mainFrame()); | |
| 3059 HTMLDocument* document = toHTMLDocument(frame->frame()->document()); | |
| 3060 const int defaultTextInputFlags = WebTextInputFlagAutocapitalizeSentences; | |
| 3061 Element* elementList[20] = { nullptr }; | |
|
kochi
2015/07/02 11:04:36
You shouldn't use an array in a loose manner like
AKV
2015/07/02 12:45:05
Done. Thanks
| |
| 3062 elementList[0] = document->getElementById("input1"); | |
|
kochi
2015/07/02 11:04:36
It would be more readable if you split lines 3062-
AKV
2015/07/02 12:45:05
Done.
| |
| 3063 document->setFocusedElement(elementList[0]); | |
| 3064 WebTextInputInfo textInputInfo = webViewImpl->textInputInfo(); | |
| 3065 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement, textInputInfo.flags); | |
| 3066 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3067 elementList[1] = document->getElementById("contenteditable1"); | |
| 3068 EXPECT_EQ(elementList[1], document->focusedElement()); | |
| 3069 textInputInfo = webViewImpl->textInputInfo(); | |
| 3070 EXPECT_EQ(WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePre viousFocusableElement, textInputInfo.flags); | |
| 3071 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3072 elementList[2] = document->getElementById("input2"); | |
| 3073 EXPECT_EQ(elementList[2], document->focusedElement()); | |
| 3074 textInputInfo = webViewImpl->textInputInfo(); | |
| 3075 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement | WebTextInputFlagListeningToKeybo ardEvents, textInputInfo.flags); | |
| 3076 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3077 elementList[3] = document->getElementById("textarea1"); | |
| 3078 EXPECT_EQ(elementList[3], document->focusedElement()); | |
| 3079 textInputInfo = webViewImpl->textInputInfo(); | |
| 3080 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
| 3081 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3082 elementList[4] = document->getElementById("input3"); | |
| 3083 EXPECT_EQ(elementList[4], document->focusedElement()); | |
| 3084 textInputInfo = webViewImpl->textInputInfo(); | |
| 3085 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
| 3086 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3087 elementList[5] = document->getElementById("textarea2"); | |
| 3088 EXPECT_EQ(elementList[5], document->focusedElement()); | |
| 3089 textInputInfo = webViewImpl->textInputInfo(); | |
| 3090 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagHavePreviousFocusableEleme nt, textInputInfo.flags); | |
| 3091 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3092 // No next element, hence focus will stay on same element. | |
| 3093 EXPECT_EQ(elementList[5], document->focusedElement()); | |
| 3094 | |
| 3095 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3096 EXPECT_EQ(elementList[4], document->focusedElement()); | |
| 3097 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3098 EXPECT_EQ(elementList[3], document->focusedElement()); | |
| 3099 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3100 EXPECT_EQ(elementList[2], document->focusedElement()); | |
| 3101 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3102 EXPECT_EQ(elementList[1], document->focusedElement()); | |
| 3103 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3104 EXPECT_EQ(elementList[0], document->focusedElement()); | |
| 3105 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3106 // No previous element, hence focus will stay on same element. | |
| 3107 EXPECT_EQ(elementList[0], document->focusedElement()); | |
| 3108 | |
| 3109 elementList[6] = document->getElementById("contenteditable2"); | |
| 3110 document->setFocusedElement(elementList[6]); | |
| 3111 textInputInfo = webViewImpl->textInputInfo(); | |
| 3112 // No Next/Previous element for elements outside form. | |
| 3113 EXPECT_NE(WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePre viousFocusableElement, textInputInfo.flags); | |
| 3114 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3115 EXPECT_EQ(elementList[6], document->focusedElement()); | |
| 3116 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3117 EXPECT_EQ(elementList[6], document->focusedElement()); | |
| 3118 | |
| 3119 elementList[7] = document->getElementById("textarea3"); | |
| 3120 document->setFocusedElement(elementList[7]); | |
| 3121 textInputInfo = webViewImpl->textInputInfo(); | |
| 3122 // No Next/Previous element for elements outside form. | |
| 3123 EXPECT_NE(defaultTextInputFlags | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusableElement, textInputInfo.flags); | |
| 3124 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3125 EXPECT_EQ(elementList[7], document->focusedElement()); | |
| 3126 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3127 EXPECT_EQ(elementList[7], document->focusedElement()); | |
| 3128 | |
| 3129 elementList[8] = document->getElementById("textarea4"); | |
| 3130 document->setFocusedElement(elementList[8]); | |
| 3131 textInputInfo = webViewImpl->textInputInfo(); | |
| 3132 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHaveNextFocusableElement, textInputInfo.flags); | |
| 3133 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3134 elementList[9] = document->getElementById("input4"); | |
| 3135 EXPECT_EQ(elementList[9], document->focusedElement()); | |
| 3136 textInputInfo = webViewImpl->textInputInfo(); | |
| 3137 EXPECT_EQ(defaultTextInputFlags | WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHaveNextFocusableElement | WebTextInputFlagHavePreviousFocusab leElement, textInputInfo.flags); | |
| 3138 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3139 elementList[10] = document->getElementById("contenteditable3"); | |
| 3140 EXPECT_EQ(elementList[10], document->focusedElement()); | |
| 3141 textInputInfo = webViewImpl->textInputInfo(); | |
| 3142 EXPECT_EQ(WebTextInputFlagListeningToKeyboardEvents | WebTextInputFlagHavePr eviousFocusableElement, textInputInfo.flags); | |
| 3143 webViewImpl->advanceFocusInForm(WebFocusTypeForward); | |
| 3144 EXPECT_EQ(elementList[10], document->focusedElement()); | |
| 3145 | |
| 3146 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3147 elementList[9] = document->getElementById("input4"); | |
| 3148 EXPECT_EQ(elementList[9], document->focusedElement()); | |
| 3149 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3150 elementList[8] = document->getElementById("textarea4"); | |
| 3151 EXPECT_EQ(elementList[8], document->focusedElement()); | |
| 3152 webViewImpl->advanceFocusInForm(WebFocusTypeBackward); | |
| 3153 EXPECT_EQ(elementList[8], document->focusedElement()); | |
| 3154 m_webViewHelper.reset(); | |
| 3155 } | |
| 3156 | |
| 3052 } // namespace blink | 3157 } // namespace blink |
| OLD | NEW |