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

Side by Side Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 1472483002: Check texture ids are valid in CopyTextureCHROMIUM apis. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
« no previous file with comments | « gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2, 0, 632 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2, 0,
633 0, 2, 2, false, false, false); 633 0, 2, 2, false, false, false);
634 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 634 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
635 635
636 // x + width > source_width 636 // x + width > source_width
637 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 1, 637 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 1,
638 1, 2, 2, false, false, false); 638 1, 2, 2, false, false, false);
639 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 639 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
640 } 640 }
641 641
642 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) {
643 glBindTexture(GL_TEXTURE_2D, textures_[0]);
644 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
645 nullptr);
646
647 glBindTexture(GL_TEXTURE_2D, textures_[1]);
648 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
649 nullptr);
650
651 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], 99993, GL_RGBA,
652 GL_UNSIGNED_BYTE, false, false, false);
653 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
654
655 glCopyTextureCHROMIUM(GL_TEXTURE_2D, 99994, textures_[1], GL_RGBA,
656 GL_UNSIGNED_BYTE, false, false, false);
657 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
658
659 glCopyTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996, GL_RGBA, GL_UNSIGNED_BYTE,
660 false, false, false);
661 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
662
663 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
664 GL_UNSIGNED_BYTE, false, false, false);
665 EXPECT_TRUE(GL_NO_ERROR == glGetError());
666 }
667
668 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) {
669 glBindTexture(GL_TEXTURE_2D, textures_[0]);
670 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
671 nullptr);
672
673 glBindTexture(GL_TEXTURE_2D, textures_[1]);
674 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
675 nullptr);
676
677 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], 99993, 1, 1, 0, 0, 1, 1,
678 false, false, false);
679 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
680
681 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99994, textures_[1], 1, 1, 0, 0, 1, 1,
682 false, false, false);
683 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
684
685 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996, 1, 1, 0, 0, 1, 1, false,
686 false, false);
687 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
688
689 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
690 0, 1, 1, false, false, false);
691 EXPECT_TRUE(GL_NO_ERROR == glGetError());
692 }
693
642 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 694 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
643 uint8 rgba_pixels[4 * 4] = {255u, 695 uint8 rgba_pixels[4 * 4] = {255u,
644 0u, 696 0u,
645 0u, 697 0u,
646 255u, 698 255u,
647 0u, 699 0u,
648 255u, 700 255u,
649 0u, 701 0u,
650 255u, 702 255u,
651 0u, 703 0u,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 uint8 green[1 * 4] = {0u, 255u, 0u, 255u}; 743 uint8 green[1 * 4] = {0u, 255u, 0u, 255u};
692 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u}; 744 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u};
693 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); 745 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent);
694 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); 746 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red);
695 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); 747 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green);
696 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); 748 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue);
697 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 749 EXPECT_TRUE(GL_NO_ERROR == glGetError());
698 } 750 }
699 751
700 } // namespace gpu 752 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698