OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <iostream> | 5 #include <iostream> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 }; | 1786 }; |
1787 | 1787 |
1788 template <> | 1788 template <> |
1789 struct FuzzTraits<ui::LatencyInfo> { | 1789 struct FuzzTraits<ui::LatencyInfo> { |
1790 static bool Fuzz(ui::LatencyInfo* p, Fuzzer* fuzzer) { | 1790 static bool Fuzz(ui::LatencyInfo* p, Fuzzer* fuzzer) { |
1791 // TODO(inferno): Add param traits for |latency_components|. | 1791 // TODO(inferno): Add param traits for |latency_components|. |
1792 int64_t trace_id = p->trace_id(); | 1792 int64_t trace_id = p->trace_id(); |
1793 bool terminated = p->terminated(); | 1793 bool terminated = p->terminated(); |
1794 uint32_t input_coordinates_size = static_cast<uint32_t>( | 1794 uint32_t input_coordinates_size = static_cast<uint32_t>( |
1795 RandInRange(ui::LatencyInfo::kMaxInputCoordinates + 1)); | 1795 RandInRange(ui::LatencyInfo::kMaxInputCoordinates + 1)); |
1796 ui::LatencyInfo::InputCoordinate | 1796 gfx::PointF input_coordinates[ui::LatencyInfo::kMaxInputCoordinates]; |
1797 input_coordinates[ui::LatencyInfo::kMaxInputCoordinates]; | |
1798 if (!FuzzParamArray( | 1797 if (!FuzzParamArray( |
1799 input_coordinates, input_coordinates_size, fuzzer)) | 1798 input_coordinates, input_coordinates_size, fuzzer)) |
1800 return false; | 1799 return false; |
1801 if (!FuzzParam(&trace_id, fuzzer)) | 1800 if (!FuzzParam(&trace_id, fuzzer)) |
1802 return false; | 1801 return false; |
1803 if (!FuzzParam(&terminated, fuzzer)) | 1802 if (!FuzzParam(&terminated, fuzzer)) |
1804 return false; | 1803 return false; |
1805 | 1804 |
1806 ui::LatencyInfo latency(trace_id, terminated); | 1805 ui::LatencyInfo latency(trace_id, terminated); |
1807 for (size_t i = 0; i < input_coordinates_size; i++) { | 1806 for (size_t i = 0; i < input_coordinates_size; i++) { |
1808 latency.AddInputCoordinate(input_coordinates[i]); | 1807 latency.AddInputCoordinate(input_coordinates[i]); |
1809 } | 1808 } |
1810 *p = latency; | 1809 *p = latency; |
1811 | 1810 |
1812 return true; | 1811 return true; |
1813 } | 1812 } |
1814 }; | 1813 }; |
1815 | 1814 |
1816 template <> | 1815 template <> |
1817 struct FuzzTraits<ui::LatencyInfo::InputCoordinate> { | |
1818 static bool Fuzz( | |
1819 ui::LatencyInfo::InputCoordinate* p, Fuzzer* fuzzer) { | |
1820 if (!FuzzParam(&p->x, fuzzer)) | |
1821 return false; | |
1822 if (!FuzzParam(&p->y, fuzzer)) | |
1823 return false; | |
1824 return true; | |
1825 } | |
1826 }; | |
1827 | |
1828 template <> | |
1829 struct FuzzTraits<url::Origin> { | 1816 struct FuzzTraits<url::Origin> { |
1830 static bool Fuzz(url::Origin* p, Fuzzer* fuzzer) { | 1817 static bool Fuzz(url::Origin* p, Fuzzer* fuzzer) { |
1831 std::string scheme = p->scheme(); | 1818 std::string scheme = p->scheme(); |
1832 std::string host = p->host(); | 1819 std::string host = p->host(); |
1833 uint16_t port = p->port(); | 1820 uint16_t port = p->port(); |
1834 if (!FuzzParam(&scheme, fuzzer)) | 1821 if (!FuzzParam(&scheme, fuzzer)) |
1835 return false; | 1822 return false; |
1836 if (!FuzzParam(&host, fuzzer)) | 1823 if (!FuzzParam(&host, fuzzer)) |
1837 return false; | 1824 return false; |
1838 if (!FuzzParam(&port, fuzzer)) | 1825 if (!FuzzParam(&port, fuzzer)) |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" | 2024 #include "tools/ipc_fuzzer/message_lib/all_message_null_macros.h" |
2038 #undef IPC_MESSAGE_DECL | 2025 #undef IPC_MESSAGE_DECL |
2039 #define IPC_MESSAGE_DECL(name, ...) \ | 2026 #define IPC_MESSAGE_DECL(name, ...) \ |
2040 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; | 2027 (*map)[static_cast<uint32_t>(name::ID)] = FuzzerHelper<name>::Fuzz; |
2041 | 2028 |
2042 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { | 2029 void PopulateFuzzerFunctionMap(FuzzerFunctionMap* map) { |
2043 #include "tools/ipc_fuzzer/message_lib/all_messages.h" | 2030 #include "tools/ipc_fuzzer/message_lib/all_messages.h" |
2044 } | 2031 } |
2045 | 2032 |
2046 } // namespace ipc_fuzzer | 2033 } // namespace ipc_fuzzer |
OLD | NEW |