| Index: Source/core/dom/AttrTest.cpp
|
| diff --git a/Source/core/dom/AttrTest.cpp b/Source/core/dom/AttrTest.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7ae6eabfe8cdbe1ca9a8cee5c76fcd232a97d452
|
| --- /dev/null
|
| +++ b/Source/core/dom/AttrTest.cpp
|
| @@ -0,0 +1,85 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/dom/Attr.h"
|
| +
|
| +#include "core/dom/Document.h"
|
| +#include <gmock/gmock.h>
|
| +#include <gtest/gtest.h>
|
| +
|
| +using namespace blink;
|
| +
|
| +namespace {
|
| +
|
| +class AttrTest : public ::testing::Test {
|
| +protected:
|
| + virtual void SetUp() override;
|
| +
|
| + PassRefPtrWillBeRawPtr<Attr> createAttribute();
|
| + const AtomicString& value() const { return m_value; }
|
| +
|
| +private:
|
| + RefPtrWillBePersistent<Document> m_document;
|
| + AtomicString m_value;
|
| +};
|
| +
|
| +void AttrTest::SetUp()
|
| +{
|
| + m_document = Document::create();
|
| + m_value = "value";
|
| +}
|
| +
|
| +PassRefPtrWillBeRawPtr<Attr> AttrTest::createAttribute()
|
| +{
|
| + return m_document->createAttribute("name", ASSERT_NO_EXCEPTION);
|
| +}
|
| +
|
| +TEST_F(AttrTest, InitialValueState)
|
| +{
|
| + RefPtrWillBeRawPtr<Attr> attr = createAttribute();
|
| + EXPECT_EQ(emptyAtom, attr->value());
|
| + EXPECT_EQ(emptyString(), attr->toNode()->nodeValue());
|
| + EXPECT_EQ(String(), attr->textContent());
|
| +}
|
| +
|
| +TEST_F(AttrTest, SetValue)
|
| +{
|
| + RefPtrWillBeRawPtr<Attr> attr = createAttribute();
|
| + attr->setValue(value());
|
| + EXPECT_EQ(value(), attr->value());
|
| + EXPECT_EQ(value(), attr->toNode()->nodeValue());
|
| + // Node::textContent() always returns String() for Attr.
|
| + EXPECT_EQ(String(), attr->textContent());
|
| +}
|
| +
|
| +TEST_F(AttrTest, SetNodeValue)
|
| +{
|
| + RefPtrWillBeRawPtr<Attr> attr = createAttribute();
|
| + attr->toNode()->setNodeValue(value());
|
| + EXPECT_EQ(value(), attr->value());
|
| + EXPECT_EQ(value(), attr->toNode()->nodeValue());
|
| + // Node::textContent() always returns String() for Attr.
|
| + EXPECT_EQ(String(), attr->textContent());
|
| +}
|
| +
|
| +TEST_F(AttrTest, SetTextContent)
|
| +{
|
| + RefPtrWillBeRawPtr<Attr> attr = createAttribute();
|
| + // Node::setTextContent() does nothing for Attr.
|
| + attr->setTextContent(value());
|
| + EXPECT_EQ(emptyAtom, attr->value());
|
| + EXPECT_EQ(emptyString(), attr->toNode()->nodeValue());
|
| + EXPECT_EQ(String(), attr->textContent());
|
| +}
|
| +
|
| +TEST_F(AttrTest, LengthOfContents)
|
| +{
|
| + RefPtrWillBeRawPtr<Attr> attr = createAttribute();
|
| + EXPECT_EQ(0u, attr->lengthOfContents());
|
| + attr->setValue(value());
|
| + EXPECT_EQ(0u, attr->lengthOfContents());
|
| +}
|
| +
|
| +} // unnamed namespace
|
|
|