Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iostream> | 8 #include <iostream> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 return false; | 702 return false; |
| 703 if (!GenerateParam(&value, generator)) | 703 if (!GenerateParam(&value, generator)) |
| 704 return false; | 704 return false; |
| 705 *p = blink::WebGamepadButton(pressed, value); | 705 *p = blink::WebGamepadButton(pressed, value); |
| 706 return true; | 706 return true; |
| 707 } | 707 } |
| 708 }; | 708 }; |
| 709 | 709 |
| 710 template <> | 710 template <> |
| 711 struct GenerateTraits<cc::CompositorFrame> { | 711 struct GenerateTraits<cc::CompositorFrame> { |
| 712 // FIXME: this should actually generate something | |
| 713 static bool Generate(cc::CompositorFrame* p, Generator* generator) { | 712 static bool Generate(cc::CompositorFrame* p, Generator* generator) { |
| 713 if (!GenerateParam(&p->metadata, generator)) | |
| 714 return false; | |
| 715 p->delegated_frame_data.reset(new cc::DelegatedFrameData); | |
|
inferno
2015/01/28 22:44:36
empty constructor for clarity everywhere
s/p->dele
inferno
2015/01/28 22:44:36
Should we be generating all of these three at once
Martin Barbella
2015/01/28 23:03:59
Yeah, it looks like we should only be generating o
Martin Barbella
2015/01/28 23:32:59
Both comments addressed.
| |
| 716 if (!GenerateParam(p->delegated_frame_data.get(), generator)) | |
| 717 return false; | |
| 718 p->gl_frame_data.reset(new cc::GLFrameData); | |
| 719 if (!GenerateParam(p->gl_frame_data.get(), generator)) | |
| 720 return false; | |
| 721 p->software_frame_data.reset(new cc::SoftwareFrameData); | |
| 722 if (!GenerateParam(p->software_frame_data.get(), generator)) | |
| 723 return false; | |
| 714 return true; | 724 return true; |
| 715 } | 725 } |
| 716 }; | 726 }; |
| 717 | 727 |
| 718 template <> | 728 template <> |
| 719 struct GenerateTraits<cc::CompositorFrameAck> { | 729 struct GenerateTraits<cc::CompositorFrameAck> { |
| 720 // FIXME: this should actually generate something | |
| 721 static bool Generate(cc::CompositorFrameAck* p, Generator* generator) { | 730 static bool Generate(cc::CompositorFrameAck* p, Generator* generator) { |
| 731 if (!GenerateParam(&p->resources, generator)) | |
| 732 return false; | |
| 733 if (!GenerateParam(&p->last_software_frame_id, generator)) | |
| 734 return false; | |
| 735 p->gl_frame_data.reset(new cc::GLFrameData); | |
| 736 if (!GenerateParam(p->gl_frame_data.get(), generator)) | |
| 737 return false; | |
| 722 return true; | 738 return true; |
| 723 } | 739 } |
| 724 }; | 740 }; |
| 741 | |
| 742 template <> | |
| 743 struct GenerateTraits<cc::DelegatedFrameData> { | |
| 744 static bool Generate(cc::DelegatedFrameData* p, Generator* generator) { | |
| 745 if (!GenerateParam(&p->device_scale_factor, generator)) | |
| 746 return false; | |
| 747 if (!GenerateParam(&p->resource_list, generator)) | |
| 748 return false; | |
| 749 if (!GenerateParam(&p->render_pass_list, generator)) | |
| 750 return false; | |
| 751 return true; | |
| 752 } | |
| 753 }; | |
| 754 | |
| 755 template <class A> | |
| 756 struct GenerateTraits<cc::ListContainer<A>> { | |
| 757 static bool Generate(cc::ListContainer<A>* p, Generator* generator) { | |
| 758 // FIXME(mbarbella): This should actually generate something. | |
|
Tom Sepez
2015/01/28 22:58:09
nit: style guide says TODO(mbarbella): ..
Martin Barbella
2015/01/28 23:32:59
Done.
| |
| 759 return true; | |
| 760 } | |
| 761 }; | |
| 762 | |
| 763 template <> | |
| 764 struct GenerateTraits<cc::QuadList> { | |
| 765 static bool Generate(cc::QuadList* p, Generator* generator) { | |
| 766 // FIXME(mbarbella): This should actually generate something. | |
| 767 return true; | |
| 768 } | |
| 769 }; | |
| 770 | |
| 771 template <> | |
| 772 struct GenerateTraits<cc::RenderPass> { | |
| 773 static bool Generate(cc::RenderPass* p, Generator* generator) { | |
| 774 if (!GenerateParam(&p->id, generator)) | |
| 775 return false; | |
| 776 if (!GenerateParam(&p->output_rect, generator)) | |
| 777 return false; | |
| 778 if (!GenerateParam(&p->damage_rect, generator)) | |
| 779 return false; | |
| 780 if (!GenerateParam(&p->transform_to_root_target, generator)) | |
| 781 return false; | |
| 782 if (!GenerateParam(&p->has_transparent_background, generator)) | |
| 783 return false; | |
| 784 if (!GenerateParam(&p->quad_list, generator)) | |
|
inferno
2015/01/28 22:44:36
please add fixme for https://code.google.com/p/chr
Martin Barbella
2015/01/28 23:03:59
I didn't add it because it doesn't seem to be gett
Martin Barbella
2015/01/28 23:32:59
Left a comment here. Could you take a look to make
| |
| 785 return false; | |
| 786 if (!GenerateParam(&p->shared_quad_state_list, generator)) | |
| 787 return false; | |
| 788 return true; | |
| 789 } | |
| 790 }; | |
| 791 | |
| 792 template <> | |
| 793 struct GenerateTraits<cc::RenderPassList> { | |
| 794 static bool Generate(cc::RenderPassList* p, Generator* generator) { | |
| 795 size_t count = RandInRange(5); | |
|
inferno
2015/01/28 22:44:36
Why just 5 ? lets probably put that 10 we use othe
Martin Barbella
2015/01/28 23:32:59
Done.
| |
| 796 for (size_t i = 0; i < count; ++i) { | |
| 797 scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | |
| 798 if (!GenerateParam(render_pass.get(), generator)) | |
| 799 return false; | |
| 800 p->push_back(render_pass.Pass()); | |
| 801 } | |
| 802 return true; | |
| 803 } | |
| 804 }; | |
| 805 | |
| 806 template <> | |
| 807 struct GenerateTraits<cc::SoftwareFrameData> { | |
| 808 static bool Generate(cc::SoftwareFrameData* p, Generator* generator) { | |
| 809 if (!GenerateParam(&p->id, generator)) | |
| 810 return false; | |
| 811 if (!GenerateParam(&p->size, generator)) | |
| 812 return false; | |
| 813 if (!GenerateParam(&p->damage_rect, generator)) | |
| 814 return false; | |
| 815 if (!GenerateParam(&p->bitmap_id, generator)) | |
| 816 return false; | |
| 817 return true; | |
| 818 } | |
| 819 }; | |
| 725 | 820 |
| 726 template <> | 821 template <> |
| 727 struct GenerateTraits<content::IndexedDBKey> { | 822 struct GenerateTraits<content::IndexedDBKey> { |
| 728 static bool Generate(content::IndexedDBKey* p, Generator* generator) { | 823 static bool Generate(content::IndexedDBKey* p, Generator* generator) { |
| 729 ++g_depth; | 824 ++g_depth; |
| 730 blink::WebIDBKeyType web_type = | 825 blink::WebIDBKeyType web_type = |
| 731 static_cast<blink::WebIDBKeyType>(RandInRange(7)); | 826 static_cast<blink::WebIDBKeyType>(RandInRange(7)); |
| 732 switch (web_type) | 827 switch (web_type) |
| 733 { | 828 { |
| 734 case blink::WebIDBKeyTypeArray: { | 829 case blink::WebIDBKeyTypeArray: { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1056 if (!GenerateParam(&x, generator)) | 1151 if (!GenerateParam(&x, generator)) |
| 1057 return false; | 1152 return false; |
| 1058 if (!GenerateParam(&y, generator)) | 1153 if (!GenerateParam(&y, generator)) |
| 1059 return false; | 1154 return false; |
| 1060 p->SetPoint(x, y); | 1155 p->SetPoint(x, y); |
| 1061 return true; | 1156 return true; |
| 1062 } | 1157 } |
| 1063 }; | 1158 }; |
| 1064 | 1159 |
| 1065 template <> | 1160 template <> |
| 1066 struct GenerateTraits<gfx::Size> { | |
| 1067 static bool Generate(gfx::Size *p, Generator* generator) { | |
| 1068 int w; | |
| 1069 int h; | |
| 1070 if (!GenerateParam(&w, generator)) | |
| 1071 return false; | |
| 1072 if (!GenerateParam(&h, generator)) | |
| 1073 return false; | |
| 1074 p->SetSize(w, h); | |
| 1075 return true; | |
| 1076 } | |
| 1077 }; | |
| 1078 | |
| 1079 template <> | |
| 1080 struct GenerateTraits<gfx::SizeF> { | |
| 1081 static bool Generate(gfx::SizeF *p, Generator* generator) { | |
| 1082 float w; | |
| 1083 float h; | |
| 1084 if (!GenerateParam(&w, generator)) | |
| 1085 return false; | |
| 1086 if (!GenerateParam(&h, generator)) | |
| 1087 return false; | |
| 1088 p->SetSize(w, h); | |
| 1089 return true; | |
| 1090 } | |
| 1091 }; | |
| 1092 | |
| 1093 template <> | |
| 1094 struct GenerateTraits<gfx::Rect> { | 1161 struct GenerateTraits<gfx::Rect> { |
| 1095 static bool Generate(gfx::Rect *p, Generator* generator) { | 1162 static bool Generate(gfx::Rect *p, Generator* generator) { |
| 1096 gfx::Point origin; | 1163 gfx::Point origin; |
| 1097 gfx::Size size; | 1164 gfx::Size size; |
| 1098 if (!GenerateParam(&origin, generator)) | 1165 if (!GenerateParam(&origin, generator)) |
| 1099 return false; | 1166 return false; |
| 1100 if (!GenerateParam(&size, generator)) | 1167 if (!GenerateParam(&size, generator)) |
| 1101 return false; | 1168 return false; |
| 1102 p->set_origin(origin); | 1169 p->set_origin(origin); |
| 1103 p->set_size(size); | 1170 p->set_size(size); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1128 if (!GenerateParam(&start, generator)) | 1195 if (!GenerateParam(&start, generator)) |
| 1129 return false; | 1196 return false; |
| 1130 if (!GenerateParam(&end, generator)) | 1197 if (!GenerateParam(&end, generator)) |
| 1131 return false; | 1198 return false; |
| 1132 *p = gfx::Range(start, end); | 1199 *p = gfx::Range(start, end); |
| 1133 return true; | 1200 return true; |
| 1134 } | 1201 } |
| 1135 }; | 1202 }; |
| 1136 | 1203 |
| 1137 template <> | 1204 template <> |
| 1205 struct GenerateTraits<gfx::Size> { | |
| 1206 static bool Generate(gfx::Size* p, Generator* generator) { | |
| 1207 int w; | |
| 1208 int h; | |
| 1209 if (!GenerateParam(&w, generator)) | |
| 1210 return false; | |
| 1211 if (!GenerateParam(&h, generator)) | |
| 1212 return false; | |
| 1213 p->SetSize(w, h); | |
| 1214 return true; | |
| 1215 } | |
| 1216 }; | |
| 1217 | |
| 1218 template <> | |
| 1219 struct GenerateTraits<gfx::SizeF> { | |
| 1220 static bool Generate(gfx::SizeF* p, Generator* generator) { | |
| 1221 float w; | |
| 1222 float h; | |
| 1223 if (!GenerateParam(&w, generator)) | |
| 1224 return false; | |
| 1225 if (!GenerateParam(&h, generator)) | |
| 1226 return false; | |
| 1227 p->SetSize(w, h); | |
| 1228 return true; | |
| 1229 } | |
| 1230 }; | |
| 1231 | |
| 1232 template <> | |
| 1233 struct GenerateTraits<gfx::Transform> { | |
| 1234 static bool Generate(gfx::Transform* p, Generator* generator) { | |
| 1235 SkMScalar matrix[16]; | |
| 1236 if (!GenerateParamArray(&matrix[0], arraysize(matrix), generator)) | |
| 1237 return false; | |
| 1238 *p = gfx::Transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], | |
| 1239 matrix[5], matrix[6], matrix[7], matrix[8], matrix[9], | |
| 1240 matrix[10], matrix[11], matrix[12], matrix[13], | |
| 1241 matrix[14], matrix[15]); | |
| 1242 return true; | |
| 1243 } | |
| 1244 }; | |
| 1245 | |
| 1246 template <> | |
| 1138 struct GenerateTraits<gfx::Vector2d> { | 1247 struct GenerateTraits<gfx::Vector2d> { |
| 1139 static bool Generate(gfx::Vector2d *p, Generator* generator) { | 1248 static bool Generate(gfx::Vector2d *p, Generator* generator) { |
| 1140 int x; | 1249 int x; |
| 1141 int y; | 1250 int y; |
| 1142 if (!GenerateParam(&x, generator)) | 1251 if (!GenerateParam(&x, generator)) |
| 1143 return false; | 1252 return false; |
| 1144 if (!GenerateParam(&y, generator)) | 1253 if (!GenerateParam(&y, generator)) |
| 1145 return false; | 1254 return false; |
| 1146 *p = gfx::Vector2d(x, y); | 1255 *p = gfx::Vector2d(x, y); |
| 1147 return true; | 1256 return true; |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 return EXIT_FAILURE; | 1757 return EXIT_FAILURE; |
| 1649 | 1758 |
| 1650 return EXIT_SUCCESS; | 1759 return EXIT_SUCCESS; |
| 1651 } | 1760 } |
| 1652 | 1761 |
| 1653 } // namespace ipc_fuzzer | 1762 } // namespace ipc_fuzzer |
| 1654 | 1763 |
| 1655 int main(int argc, char** argv) { | 1764 int main(int argc, char** argv) { |
| 1656 return ipc_fuzzer::GenerateMain(argc, argv); | 1765 return ipc_fuzzer::GenerateMain(argc, argv); |
| 1657 } | 1766 } |
| OLD | NEW |