Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/html/ImageData.h" | |
| 6 | |
| 7 #include "core/dom/ExceptionCode.h" | |
| 8 #include "platform/geometry/IntSize.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 namespace { | |
| 13 | |
| 14 class ImageDataTest : public ::testing::Test { | |
| 15 protected: | |
| 16 ImageDataTest(){}; | |
| 17 void TearDown(){}; | |
| 18 }; | |
| 19 | |
| 20 TEST_F(ImageDataTest, NegativeAndZeroIntSizeTest) { | |
| 21 ImageData* imageData; | |
| 22 | |
| 23 imageData = ImageData::create(IntSize(0, 10)); | |
| 24 EXPECT_EQ(imageData, nullptr); | |
| 25 | |
| 26 imageData = ImageData::create(IntSize(10, 0)); | |
| 27 EXPECT_EQ(imageData, nullptr); | |
| 28 | |
| 29 imageData = ImageData::create(IntSize(0, 0)); | |
| 30 EXPECT_EQ(imageData, nullptr); | |
| 31 | |
| 32 imageData = ImageData::create(IntSize(-1, 10)); | |
| 33 EXPECT_EQ(imageData, nullptr); | |
| 34 | |
| 35 imageData = ImageData::create(IntSize(10, -1)); | |
| 36 EXPECT_EQ(imageData, nullptr); | |
| 37 | |
| 38 imageData = ImageData::create(IntSize(-1, -1)); | |
| 39 EXPECT_EQ(imageData, nullptr); | |
| 40 } | |
| 41 | |
| 42 TEST_F(ImageDataTest, CreateImageDataTooBig) { | |
| 43 DummyExceptionStateForTesting exceptionState; | |
| 44 ImageData* tooBigImageData = ImageData::create(32767, 32767, exceptionState); | |
|
Justin Novosad
2017/03/21 17:07:23
You need to add a comment here to explain the rati
| |
| 45 EXPECT_EQ(tooBigImageData, nullptr); | |
| 46 EXPECT_TRUE(exceptionState.hadException()); | |
| 47 EXPECT_EQ(exceptionState.code(), V8RangeError); | |
| 48 } | |
| 49 | |
| 50 } // namspace | |
| 51 } // namespace blink | |
| OLD | NEW |