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

Side by Side Diff: cc/base/tiling_data_unittest.cc

Issue 774763004: Use EXPECT_EQ when possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/base/tiling_data.h" 5 #include "cc/base/tiling_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 EXPECT_EQ(10, data.num_tiles_y()); 768 EXPECT_EQ(10, data.num_tiles_y());
769 769
770 data.SetMaxTextureSize(gfx::Size(8, 5)); 770 data.SetMaxTextureSize(gfx::Size(8, 5));
771 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size()); 771 EXPECT_EQ(gfx::Size(8, 5), data.max_texture_size());
772 EXPECT_EQ(3, data.num_tiles_x()); 772 EXPECT_EQ(3, data.num_tiles_x());
773 EXPECT_EQ(10, data.num_tiles_y()); 773 EXPECT_EQ(10, data.num_tiles_y());
774 } 774 }
775 775
776 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsEmpty) { 776 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBoundsEmpty) {
777 TilingData empty_total_size(gfx::Size(0, 0), gfx::Size(8, 8), true); 777 TilingData empty_total_size(gfx::Size(0, 0), gfx::Size(8, 8), true);
778 EXPECT_RECT_EQ( 778 EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
779 gfx::Rect(), 779 gfx::Rect()));
780 empty_total_size.ExpandRectIgnoringBordersToTileBounds(gfx::Rect())); 780 EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
781 EXPECT_RECT_EQ(gfx::Rect(), 781 gfx::Rect(100, 100, 100, 100)));
782 empty_total_size.ExpandRectIgnoringBordersToTileBounds( 782 EXPECT_EQ(gfx::Rect(), empty_total_size.ExpandRectIgnoringBordersToTileBounds(
783 gfx::Rect(100, 100, 100, 100))); 783 gfx::Rect(100, 100)));
784 EXPECT_RECT_EQ(gfx::Rect(),
785 empty_total_size.ExpandRectIgnoringBordersToTileBounds(
786 gfx::Rect(100, 100)));
787 784
788 TilingData empty_max_texture_size(gfx::Size(8, 8), gfx::Size(0, 0), true); 785 TilingData empty_max_texture_size(gfx::Size(8, 8), gfx::Size(0, 0), true);
789 EXPECT_RECT_EQ(gfx::Rect(), 786 EXPECT_EQ(gfx::Rect(),
790 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds( 787 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
791 gfx::Rect())); 788 gfx::Rect()));
792 EXPECT_RECT_EQ(gfx::Rect(), 789 EXPECT_EQ(gfx::Rect(),
793 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds( 790 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
794 gfx::Rect(100, 100, 100, 100))); 791 gfx::Rect(100, 100, 100, 100)));
795 EXPECT_RECT_EQ(gfx::Rect(), 792 EXPECT_EQ(gfx::Rect(),
796 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds( 793 empty_max_texture_size.ExpandRectIgnoringBordersToTileBounds(
797 gfx::Rect(100, 100))); 794 gfx::Rect(100, 100)));
798 } 795 }
799 796
800 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBounds) { 797 TEST(TilingDataTest, ExpandRectIgnoringBordersToTileBounds) {
801 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true); 798 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
802 799
803 // Small rect at origin rounds up to tile 0, 0. 800 // Small rect at origin rounds up to tile 0, 0.
804 gfx::Rect at_origin_src(1, 1); 801 gfx::Rect at_origin_src(1, 1);
805 gfx::Rect at_origin_result(data.TileBounds(0, 0)); 802 gfx::Rect at_origin_result(data.TileBounds(0, 0));
806 EXPECT_NE(at_origin_src, at_origin_result); 803 EXPECT_NE(at_origin_src, at_origin_result);
807 EXPECT_RECT_EQ(at_origin_result, 804 EXPECT_EQ(at_origin_result,
808 data.ExpandRectIgnoringBordersToTileBounds(at_origin_src)); 805 data.ExpandRectIgnoringBordersToTileBounds(at_origin_src));
809 806
810 // Arbitrary internal rect. 807 // Arbitrary internal rect.
811 gfx::Rect rect_src(6, 6, 1, 3); 808 gfx::Rect rect_src(6, 6, 1, 3);
812 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4) 809 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
813 // Tile 2, 3 => gfx::Rect(4, 6, 4, 4) 810 // Tile 2, 3 => gfx::Rect(4, 6, 4, 4)
814 gfx::Rect rect_result( 811 gfx::Rect rect_result(
815 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(2, 3))); 812 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(2, 3)));
816 EXPECT_NE(rect_src, rect_result); 813 EXPECT_NE(rect_src, rect_result);
817 EXPECT_RECT_EQ(rect_result, 814 EXPECT_EQ(rect_result, data.ExpandRectIgnoringBordersToTileBounds(rect_src));
818 data.ExpandRectIgnoringBordersToTileBounds(rect_src));
819 815
820 // On tile bounds does not round up to next tile (ignores the border). 816 // On tile bounds does not round up to next tile (ignores the border).
821 gfx::Rect border_rect_src( 817 gfx::Rect border_rect_src(
822 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4))); 818 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
823 gfx::Rect border_rect_result( 819 gfx::Rect border_rect_result(
824 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4))); 820 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
825 EXPECT_RECT_EQ(border_rect_result, 821 EXPECT_EQ(border_rect_result,
826 data.ExpandRectIgnoringBordersToTileBounds(border_rect_src)); 822 data.ExpandRectIgnoringBordersToTileBounds(border_rect_src));
827 823
828 // Equal to tiling rect. 824 // Equal to tiling rect.
829 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()), 825 EXPECT_EQ(gfx::Rect(data.tiling_size()),
830 data.ExpandRectIgnoringBordersToTileBounds( 826 data.ExpandRectIgnoringBordersToTileBounds(
831 gfx::Rect(data.tiling_size()))); 827 gfx::Rect(data.tiling_size())));
832 828
833 // Containing, but larger than tiling rect. 829 // Containing, but larger than tiling rect.
834 EXPECT_RECT_EQ( 830 EXPECT_EQ(gfx::Rect(data.tiling_size()),
835 gfx::Rect(data.tiling_size()), 831 data.ExpandRectIgnoringBordersToTileBounds(gfx::Rect(100, 100)));
836 data.ExpandRectIgnoringBordersToTileBounds(gfx::Rect(100, 100)));
837 832
838 // Non-intersecting with tiling rect. 833 // Non-intersecting with tiling rect.
839 gfx::Rect non_intersect(200, 200, 100, 100); 834 gfx::Rect non_intersect(200, 200, 100, 100);
840 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size()))); 835 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
841 EXPECT_RECT_EQ(gfx::Rect(), 836 EXPECT_EQ(gfx::Rect(),
842 data.ExpandRectIgnoringBordersToTileBounds(non_intersect)); 837 data.ExpandRectIgnoringBordersToTileBounds(non_intersect));
843 838
844 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true); 839 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
845 840
846 // Inside other tile border texels doesn't include other tiles. 841 // Inside other tile border texels doesn't include other tiles.
847 gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); 842 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
848 inner_rect_src.Inset(data2.border_texels(), data.border_texels()); 843 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
849 gfx::Rect inner_rect_result(data2.TileBounds(1, 1)); 844 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
850 gfx::Rect expanded = 845 gfx::Rect expanded =
851 data2.ExpandRectIgnoringBordersToTileBounds(inner_rect_src); 846 data2.ExpandRectIgnoringBordersToTileBounds(inner_rect_src);
852 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); 847 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
853 } 848 }
854 849
855 TEST(TilingDataTest, ExpandRectToTileBounds) { 850 TEST(TilingDataTest, ExpandRectToTileBounds) {
856 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true); 851 TilingData data(gfx::Size(4, 4), gfx::Size(16, 32), true);
857 852
858 // Small rect at origin rounds up to tile 0, 0. 853 // Small rect at origin rounds up to tile 0, 0.
859 gfx::Rect at_origin_src(1, 1); 854 gfx::Rect at_origin_src(1, 1);
860 gfx::Rect at_origin_result(data.TileBounds(0, 0)); 855 gfx::Rect at_origin_result(data.TileBounds(0, 0));
861 EXPECT_NE(at_origin_src, at_origin_result); 856 EXPECT_NE(at_origin_src, at_origin_result);
862 EXPECT_RECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src)); 857 EXPECT_EQ(at_origin_result, data.ExpandRectToTileBounds(at_origin_src));
863 858
864 // Arbitrary internal rect. 859 // Arbitrary internal rect.
865 gfx::Rect rect_src(6, 6, 1, 3); 860 gfx::Rect rect_src(6, 6, 1, 3);
866 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4) 861 // Tile 2, 2 => gfx::Rect(4, 4, 4, 4)
867 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4) 862 // Tile 3, 4 => gfx::Rect(6, 8, 4, 4)
868 gfx::Rect rect_result( 863 gfx::Rect rect_result(
869 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4))); 864 gfx::UnionRects(data.TileBounds(2, 2), data.TileBounds(3, 4)));
870 EXPECT_NE(rect_src, rect_result); 865 EXPECT_NE(rect_src, rect_result);
871 EXPECT_RECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src)); 866 EXPECT_EQ(rect_result, data.ExpandRectToTileBounds(rect_src));
872 867
873 // On tile bounds rounds up to next tile (since border overlaps). 868 // On tile bounds rounds up to next tile (since border overlaps).
874 gfx::Rect border_rect_src( 869 gfx::Rect border_rect_src(
875 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4))); 870 gfx::UnionRects(data.TileBounds(1, 2), data.TileBounds(3, 4)));
876 gfx::Rect border_rect_result( 871 gfx::Rect border_rect_result(
877 gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5))); 872 gfx::UnionRects(data.TileBounds(0, 1), data.TileBounds(4, 5)));
878 EXPECT_RECT_EQ(border_rect_result, 873 EXPECT_EQ(border_rect_result, data.ExpandRectToTileBounds(border_rect_src));
879 data.ExpandRectToTileBounds(border_rect_src));
880 874
881 // Equal to tiling rect. 875 // Equal to tiling rect.
882 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()), 876 EXPECT_EQ(gfx::Rect(data.tiling_size()),
883 data.ExpandRectToTileBounds(gfx::Rect(data.tiling_size()))); 877 data.ExpandRectToTileBounds(gfx::Rect(data.tiling_size())));
884 878
885 // Containing, but larger than tiling rect. 879 // Containing, but larger than tiling rect.
886 EXPECT_RECT_EQ(gfx::Rect(data.tiling_size()), 880 EXPECT_EQ(gfx::Rect(data.tiling_size()),
887 data.ExpandRectToTileBounds(gfx::Rect(100, 100))); 881 data.ExpandRectToTileBounds(gfx::Rect(100, 100)));
888 882
889 // Non-intersecting with tiling rect. 883 // Non-intersecting with tiling rect.
890 gfx::Rect non_intersect(200, 200, 100, 100); 884 gfx::Rect non_intersect(200, 200, 100, 100);
891 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size()))); 885 EXPECT_FALSE(non_intersect.Intersects(gfx::Rect(data.tiling_size())));
892 EXPECT_RECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect)); 886 EXPECT_EQ(gfx::Rect(), data.ExpandRectToTileBounds(non_intersect));
893 887
894 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true); 888 TilingData data2(gfx::Size(8, 8), gfx::Size(32, 64), true);
895 889
896 // Inside other tile border texels doesn't include other tiles. 890 // Inside other tile border texels doesn't include other tiles.
897 gfx::Rect inner_rect_src(data2.TileBounds(1, 1)); 891 gfx::Rect inner_rect_src(data2.TileBounds(1, 1));
898 inner_rect_src.Inset(data2.border_texels(), data.border_texels()); 892 inner_rect_src.Inset(data2.border_texels(), data.border_texels());
899 gfx::Rect inner_rect_result(data2.TileBounds(1, 1)); 893 gfx::Rect inner_rect_result(data2.TileBounds(1, 1));
900 gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src); 894 gfx::Rect expanded = data2.ExpandRectToTileBounds(inner_rect_src);
901 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString()); 895 EXPECT_EQ(inner_rect_result.ToString(), expanded.ToString());
902 } 896 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 EXPECT_EQ(50, data.TileSizeX(3)); 940 EXPECT_EQ(50, data.TileSizeX(3));
947 EXPECT_EQ(4, data.num_tiles_x()); 941 EXPECT_EQ(4, data.num_tiles_x());
948 942
949 EXPECT_EQ(50, data.TileSizeY(0)); 943 EXPECT_EQ(50, data.TileSizeY(0));
950 EXPECT_EQ(20, data.TileSizeY(1)); 944 EXPECT_EQ(20, data.TileSizeY(1));
951 EXPECT_EQ(20, data.TileSizeY(2)); 945 EXPECT_EQ(20, data.TileSizeY(2));
952 EXPECT_EQ(20, data.TileSizeY(3)); 946 EXPECT_EQ(20, data.TileSizeY(3));
953 EXPECT_EQ(35, data.TileSizeY(4)); 947 EXPECT_EQ(35, data.TileSizeY(4));
954 EXPECT_EQ(5, data.num_tiles_y()); 948 EXPECT_EQ(5, data.num_tiles_y());
955 949
956 EXPECT_RECT_EQ(gfx::Rect(70, 50), data.TileBounds(0, 0)); 950 EXPECT_EQ(gfx::Rect(70, 50), data.TileBounds(0, 0));
957 EXPECT_RECT_EQ(gfx::Rect(70, 50, 40, 20), data.TileBounds(1, 1)); 951 EXPECT_EQ(gfx::Rect(70, 50, 40, 20), data.TileBounds(1, 1));
958 EXPECT_RECT_EQ(gfx::Rect(110, 110, 40, 35), data.TileBounds(2, 4)); 952 EXPECT_EQ(gfx::Rect(110, 110, 40, 35), data.TileBounds(2, 4));
959 EXPECT_RECT_EQ(gfx::Rect(150, 70, 50, 20), data.TileBounds(3, 2)); 953 EXPECT_EQ(gfx::Rect(150, 70, 50, 20), data.TileBounds(3, 2));
960 EXPECT_RECT_EQ(gfx::Rect(150, 110, 50, 35), data.TileBounds(3, 4)); 954 EXPECT_EQ(gfx::Rect(150, 110, 50, 35), data.TileBounds(3, 4));
961 955
962 EXPECT_RECT_EQ(gfx::Rect(100, 80), data.TileBoundsWithBorder(0, 0)); 956 EXPECT_EQ(gfx::Rect(100, 80), data.TileBoundsWithBorder(0, 0));
963 EXPECT_RECT_EQ(gfx::Rect(40, 20, 100, 80), data.TileBoundsWithBorder(1, 1)); 957 EXPECT_EQ(gfx::Rect(40, 20, 100, 80), data.TileBoundsWithBorder(1, 1));
964 EXPECT_RECT_EQ(gfx::Rect(80, 80, 100, 65), data.TileBoundsWithBorder(2, 4)); 958 EXPECT_EQ(gfx::Rect(80, 80, 100, 65), data.TileBoundsWithBorder(2, 4));
965 EXPECT_RECT_EQ(gfx::Rect(120, 40, 80, 80), data.TileBoundsWithBorder(3, 2)); 959 EXPECT_EQ(gfx::Rect(120, 40, 80, 80), data.TileBoundsWithBorder(3, 2));
966 EXPECT_RECT_EQ(gfx::Rect(120, 80, 80, 65), data.TileBoundsWithBorder(3, 4)); 960 EXPECT_EQ(gfx::Rect(120, 80, 80, 65), data.TileBoundsWithBorder(3, 4));
967 961
968 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(0)); 962 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(0));
969 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(69)); 963 EXPECT_EQ(0, data.TileXIndexFromSrcCoord(69));
970 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(70)); 964 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(70));
971 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(109)); 965 EXPECT_EQ(1, data.TileXIndexFromSrcCoord(109));
972 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(110)); 966 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(110));
973 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(149)); 967 EXPECT_EQ(2, data.TileXIndexFromSrcCoord(149));
974 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(150)); 968 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(150));
975 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(199)); 969 EXPECT_EQ(3, data.TileXIndexFromSrcCoord(199));
976 970
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 expected.push_back(std::make_pair(2, 2)); 1947 expected.push_back(std::make_pair(2, 2));
1954 expected.push_back(std::make_pair(2, 1)); 1948 expected.push_back(std::make_pair(2, 1));
1955 expected.push_back(std::make_pair(2, 0)); 1949 expected.push_back(std::make_pair(2, 0));
1956 1950
1957 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); 1951 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected);
1958 } 1952 }
1959 1953
1960 } // namespace 1954 } // namespace
1961 1955
1962 } // namespace cc 1956 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/scrollbar_animation_controller_thinning_unittest.cc ('k') | cc/blink/web_layer_impl_fixed_bounds_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698