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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSelectElementTest.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/html/HTMLSelectElement.h" 5 #include "core/html/HTMLSelectElement.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/html/HTMLDocument.h" 8 #include "core/html/HTMLDocument.h"
9 #include "core/html/HTMLFormElement.h" 9 #include "core/html/HTMLFormElement.h"
10 #include "core/html/forms/FormController.h" 10 #include "core/html/forms/FormController.h"
11 #include "core/loader/EmptyClients.h" 11 #include "core/loader/EmptyClients.h"
12 #include "core/testing/DummyPageHolder.h" 12 #include "core/testing/DummyPageHolder.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class HTMLSelectElementTest : public::testing::Test { 17 class HTMLSelectElementTest : public::testing::Test {
18 protected: 18 protected:
19 void SetUp() override; 19 void SetUp() override;
20 HTMLDocument& document() const { return *m_document; } 20 HTMLDocument& document() const { return *m_document; }
21 21
22 private: 22 private:
23 OwnPtr<DummyPageHolder> m_dummyPageHolder; 23 OwnPtr<DummyPageHolder> m_dummyPageHolder;
24 RefPtrWillBePersistent<HTMLDocument> m_document; 24 Persistent<HTMLDocument> m_document;
25 }; 25 };
26 26
27 void HTMLSelectElementTest::SetUp() 27 void HTMLSelectElementTest::SetUp()
28 { 28 {
29 Page::PageClients pageClients; 29 Page::PageClients pageClients;
30 fillWithEmptyClients(pageClients); 30 fillWithEmptyClients(pageClients);
31 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ; 31 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600), &pageClients) ;
32 32
33 m_document = toHTMLDocument(&m_dummyPageHolder->document()); 33 m_document = toHTMLDocument(&m_dummyPageHolder->document());
34 m_document->setMimeType("text/html"); 34 m_document->setMimeType("text/html");
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 HTMLOptionElement* option = toHTMLOptionElement(document().getElementByI d("o2")); 290 HTMLOptionElement* option = toHTMLOptionElement(document().getElementByI d("o2"));
291 EXPECT_EQ("o1", select->previousSelectableOption(option)->fastGetAttribu te(HTMLNames::idAttr)); 291 EXPECT_EQ("o1", select->previousSelectableOption(option)->fastGetAttribu te(HTMLNames::idAttr));
292 } 292 }
293 } 293 }
294 294
295 TEST_F(HTMLSelectElementTest, ActiveSelectionEndAfterOptionRemoval) 295 TEST_F(HTMLSelectElementTest, ActiveSelectionEndAfterOptionRemoval)
296 { 296 {
297 document().documentElement()->setInnerHTML("<select><optgroup><option select ed>o1</option></optgroup></select>", ASSERT_NO_EXCEPTION); 297 document().documentElement()->setInnerHTML("<select><optgroup><option select ed>o1</option></optgroup></select>", ASSERT_NO_EXCEPTION);
298 document().view()->updateAllLifecyclePhases(); 298 document().view()->updateAllLifecyclePhases();
299 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d()); 299 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d());
300 RefPtrWillBeRawPtr<HTMLOptionElement> option = toHTMLOptionElement(select->f irstChild()->firstChild()); 300 RawPtr<HTMLOptionElement> option = toHTMLOptionElement(select->firstChild()- >firstChild());
301 EXPECT_EQ(1, select->activeSelectionEndListIndex()); 301 EXPECT_EQ(1, select->activeSelectionEndListIndex());
302 select->firstChild()->removeChild(option, ASSERT_NO_EXCEPTION); 302 select->firstChild()->removeChild(option, ASSERT_NO_EXCEPTION);
303 EXPECT_EQ(-1, select->activeSelectionEndListIndex()); 303 EXPECT_EQ(-1, select->activeSelectionEndListIndex());
304 select->appendChild(option, ASSERT_NO_EXCEPTION); 304 select->appendChild(option, ASSERT_NO_EXCEPTION);
305 EXPECT_EQ(1, select->activeSelectionEndListIndex()); 305 EXPECT_EQ(1, select->activeSelectionEndListIndex());
306 } 306 }
307 307
308 TEST_F(HTMLSelectElementTest, DefaultToolTip) 308 TEST_F(HTMLSelectElementTest, DefaultToolTip)
309 { 309 {
310 document().documentElement()->setInnerHTML("<select size=4><option value=""> Placeholder</option><optgroup><option>o2</option></optgroup></select>", ASSERT_N O_EXCEPTION); 310 document().documentElement()->setInnerHTML("<select size=4><option value=""> Placeholder</option><optgroup><option>o2</option></optgroup></select>", ASSERT_N O_EXCEPTION);
311 document().view()->updateAllLifecyclePhases(); 311 document().view()->updateAllLifecyclePhases();
312 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d()); 312 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d());
313 RefPtrWillBeRawPtr<Element> option = toElement(select->firstChild()); 313 RawPtr<Element> option = toElement(select->firstChild());
314 RefPtrWillBeRawPtr<Element> optgroup = toElement(option->nextSibling()); 314 RawPtr<Element> optgroup = toElement(option->nextSibling());
315 315
316 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT without FORM and without required attribute should return null string."; 316 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT without FORM and without required attribute should return null string.";
317 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); 317 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
318 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); 318 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
319 319
320 select->setBooleanAttribute(HTMLNames::requiredAttr, true); 320 select->setBooleanAttribute(HTMLNames::requiredAttr, true);
321 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT without FORM and with required attribute should ret urn a valueMissing message."; 321 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT without FORM and with required attribute should ret urn a valueMissing message.";
322 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); 322 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
323 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); 323 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
324 324
325 RefPtrWillBeRawPtr<HTMLFormElement> form = HTMLFormElement::create(document( )); 325 RawPtr<HTMLFormElement> form = HTMLFormElement::create(document());
326 document().body()->appendChild(form.get()); 326 document().body()->appendChild(form.get());
327 form->appendChild(select); 327 form->appendChild(select);
328 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT with FORM and required attribute should return a va lueMissing message."; 328 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT with FORM and required attribute should return a va lueMissing message.";
329 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); 329 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
330 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); 330 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
331 331
332 form->setBooleanAttribute(HTMLNames::novalidateAttr, true); 332 form->setBooleanAttribute(HTMLNames::novalidateAttr, true);
333 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT with FORM[novalidate] and required attribute should return null string."; 333 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT with FORM[novalidate] and required attribute should return null string.";
334 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); 334 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
335 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); 335 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
336 336
337 option->remove(); 337 option->remove();
338 optgroup->remove(); 338 optgroup->remove();
339 EXPECT_EQ(String(), option->defaultToolTip()); 339 EXPECT_EQ(String(), option->defaultToolTip());
340 EXPECT_EQ(String(), optgroup->defaultToolTip()); 340 EXPECT_EQ(String(), optgroup->defaultToolTip());
341 } 341 }
342 342
343 } // namespace blink 343 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698