From 7d829960bfce44809d609ec86b598e0164553f0d Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Sat, 22 Jul 2023 18:43:39 +0200 Subject: [PATCH 1/6] feat: update the sdk constraints and depedencies --- pubspec.lock | 324 +++++++++++++++++++++++++-------------------------- pubspec.yaml | 30 ++--- 2 files changed, 173 insertions(+), 181 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index c98c21b..18857c2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,114 +5,114 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "0c80aeab9bc807ab10022cd3b2f4cf2ecdf231949dc1ddd9442406a003f19201" + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "52.0.0" + version: "61.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: cd8ee83568a77f3ae6b913a36093a1c9b1264e7cb7f834d9ddd2311dade9c1f4 + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.13.0" archive: dependency: transitive description: name: archive - sha256: d6347d54a2d8028e0437e3c099f66fdb8ae02c4720c1e7534c9f24c10351f85d + sha256: "0c8368c9b3f0abbc193b9d6133649a614204b528982bebc7026372d61677ce3a" url: "https://pub.dev" source: hosted - version: "3.3.6" + version: "3.3.7" args: dependency: transitive description: name: args - sha256: "139d809800a412ebb26a3892da228b2d0ba36f0ef5d9a82166e5e52ec8d61611" + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.2" async: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" audioplayers: dependency: transitive description: name: audioplayers - sha256: "16451eab798b23ad9307aef6f9ca62bb8fb06542af8810eead0d236d3fd40a42" + sha256: "61583554386721772f9309f509e17712865b38565a903c761f96b1115a979282" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.1.0" audioplayers_android: dependency: transitive description: name: audioplayers_android - sha256: b2c833e6f718b6b030454e329931229afafe9327fdb002874dd544dc8bf2484d + sha256: dbdc9b7f2aa2440314c638aa55aadd45c7705e8340d5eddf2e3fb8da32d4ae2c url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "3.0.2" audioplayers_darwin: dependency: transitive description: name: audioplayers_darwin - sha256: e7a3c8759bf11ecfe4b20df338bf9f3d37c7719a5761c46a3833aba0ceeaacff + sha256: "6aea96df1d12f7ad5a71d88c6d1b22a216211a9564219920124c16768e456e9d" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "4.1.0" audioplayers_linux: dependency: transitive description: name: audioplayers_linux - sha256: e95b65e1f4d4764601dac5e65f8d8186fc29401043ab020f1dacec483d708707 + sha256: "396b62ac62c92dd26c3bc5106583747f57a8b325ebd2b41e5576f840cfc61338" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "2.1.0" audioplayers_platform_interface: dependency: transitive description: name: audioplayers_platform_interface - sha256: "178581a44cb685fd798d2108111d2e98cca3400e30b9c3a05546f124fb37f600" + sha256: f7daaed4659143094151ecf6bacd927d29ab8acffba98c110c59f0b81ae51143 url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "5.0.1" audioplayers_web: dependency: transitive description: name: audioplayers_web - sha256: "859ba09be2a57e57a787273f18c8cf0d9b61383870c5ee4b5632fe9adbc37edf" + sha256: ec84fd46eed1577148ed4113f5998a36a18da4fce7170c37ce3e21b631393339 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "3.1.0" audioplayers_windows: dependency: transitive description: name: audioplayers_windows - sha256: "622e01c4c357c2aaf1b956c3a0f89d97c3cb40315c03f16e3b6c2a31ff9c38bc" + sha256: "1d3aaac98a192b8488167711ba1e67d8b96333e8d0572ede4e2912e5bbce69a3" url: "https://pub.dev" source: hosted - version: "1.1.3" + version: "2.0.2" bloc: dependency: "direct main" description: name: bloc - sha256: "658a5ae59edcf1e58aac98b000a71c762ad8f46f1394c34a52050cafb3e11a80" + sha256: "3820f15f502372d979121de1f6b97bfcf1630ebff8fe1d52fb2b0bfa49be5b49" url: "https://pub.dev" source: hosted - version: "8.1.1" + version: "8.1.2" bloc_test: dependency: "direct dev" description: name: bloc_test - sha256: ffbb60c17ee3d8e3784cb78071088e353199057233665541e8ac6cd438dca8ad + sha256: "43d5b2f3d09ba768d6b611151bdf20ca141ffb46e795eb9550a58c9c2f4eae3f" url: "https://pub.dev" source: hosted - version: "9.1.1" + version: "9.1.3" boolean_selector: dependency: transitive description: @@ -125,10 +125,10 @@ packages: dependency: transitive description: name: build - sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.4.1" build_config: dependency: transitive description: @@ -141,34 +141,34 @@ packages: dependency: transitive description: name: build_daemon - sha256: "6bc5544ea6ce4428266e7ea680e945c68806c4aae2da0eb5e9ccf38df8d6acbf" + sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "4.0.0" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "7c35a3a7868626257d8aee47b51c26b9dba11eaddf3431117ed2744951416aab" + sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.1" build_runner: dependency: "direct dev" description: name: build_runner - sha256: b0a8a7b8a76c493e85f1b84bffa0588859a06197863dba8c9036b15581fd9727 + sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.4.6" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: "14febe0f5bac5ae474117a36099b4de6f1dbc52df6c5e55534b3da9591bf4292" + sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" url: "https://pub.dev" source: hosted - version: "7.2.7" + version: "7.2.10" built_collection: dependency: transitive description: @@ -181,26 +181,26 @@ packages: dependency: transitive description: name: built_value - sha256: "169565c8ad06adb760c3645bf71f00bff161b00002cace266cad42c5d22a7725" + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" url: "https://pub.dev" source: hosted - version: "8.4.3" + version: "8.6.1" characters: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" checked_yaml: dependency: transitive description: name: checked_yaml - sha256: "3d1505d91afa809d177efd4eed5bb0eb65805097a1463abdd2add076effae311" + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.3" clock: dependency: transitive description: @@ -213,18 +213,18 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189" url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.0" collection: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" convert: dependency: transitive description: @@ -237,26 +237,26 @@ packages: dependency: transitive description: name: coverage - sha256: "961c4aebd27917269b1896382c7cb1b1ba81629ba669ba09c27a7e5710ec9040" + sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" url: "https://pub.dev" source: hosted - version: "1.6.2" + version: "1.6.3" crypto: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" dart_style: dependency: transitive description: name: dart_style - sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.3.2" diff_match_patch: dependency: transitive description: @@ -285,10 +285,10 @@ packages: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" file: dependency: transitive description: @@ -309,18 +309,18 @@ packages: dependency: "direct main" description: name: flame - sha256: "3bd6699af5afbe0ff680d26a3b5f10ae59aeced3b50c020b03821501dfec5ea6" + sha256: "12db9de3cd31b86465b0c1ea173020fb71b15df424ca01b665fa5300b24864c8" url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "1.8.1" flame_audio: dependency: "direct main" description: name: flame_audio - sha256: "11805e414473a15111be9a08439bb6ab3923546233c4edeb3b886f70868adc8a" + sha256: "70bca49b3541f47f4772f79fc4ef2af6419961a5b9a46fd340f0f1d716acd1da" url: "https://pub.dev" source: hosted - version: "1.4.1" + version: "2.0.4" flame_behaviors: dependency: "direct main" description: @@ -333,18 +333,18 @@ packages: dependency: "direct dev" description: name: flame_test - sha256: b9464cd23e5bc8c448cc9518ab8ca048696d461c3f5c2287b198254936da3c55 + sha256: "0b6e63c5d19a39524fcbc8e5b16a2f9babc5a420d11487a6cd06732f9a455dcc" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.0" flame_tiled: dependency: "direct main" description: name: flame_tiled - sha256: "9df019f83aaf4b2b5333f06cb95892c5e1232b54d25f049a95aa790422f8a952" + sha256: "2145d63c5f62ffe357bf31ce18b287f68b1cff6c216e1ea4b01fdcf0cd878f3a" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.0" flutter: dependency: "direct main" description: flutter @@ -354,10 +354,10 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "434951eea948dbe87f737b674281465f610b8259c16c097b8163ce138749a775" + sha256: e74efb89ee6945bcbce74a5b3a5a3376b088e5f21f55c263fc38cbdc6237faae url: "https://pub.dev" source: hosted - version: "8.1.2" + version: "8.1.3" flutter_localizations: dependency: "direct main" description: flutter @@ -377,18 +377,18 @@ packages: dependency: "direct dev" description: name: freezed - sha256: e819441678f1679b719008ff2ff0ef045d66eed9f9ec81166ca0d9b02a187454 + sha256: "2df89855fe181baae3b6d714dc3c4317acf4fccd495a6f36e5e00f24144c6c3b" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.1" freezed_annotation: dependency: "direct main" description: name: freezed_annotation - sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338 + sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.1" frontend_server_client: dependency: transitive description: @@ -401,34 +401,34 @@ packages: dependency: "direct main" description: name: get_it - sha256: "290fde3a86072e4b37dbb03c07bec6126f0ecc28dad403c12ffe2e5a2d751ab7" + sha256: "529de303c739fca98cd7ece5fca500d8ff89649f1bb4b4e94fb20954abcd7468" url: "https://pub.dev" source: hosted - version: "7.2.0" + version: "7.6.0" glob: dependency: transitive description: name: glob - sha256: "4515b5b6ddb505ebdd242a5f2cc5d22d3d6a80013789debfbda7777f47ea308c" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" graphs: dependency: transitive description: name: graphs - sha256: f9e130f3259f52d26f0cfc0e964513796dafed572fa52e45d2f8d6ca14db39b2 + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.3.1" http: dependency: transitive description: name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "0.13.5" + version: "0.13.6" http_multi_server: dependency: transitive description: @@ -449,10 +449,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6 url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.18.0" io: dependency: transitive description: @@ -465,34 +465,34 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" json_annotation: dependency: transitive description: name: json_annotation - sha256: c33da08e136c3df0190bd5bbe51ae1df4a7d96e7954d1d7249fea2968a72d317 + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.8.1" logging: dependency: transitive description: name: logging - sha256: "04094f2eb032cbb06c6f6e8d3607edcfcb0455e2bb6cbc010cb01171dcb64e6d" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -505,10 +505,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -537,18 +537,18 @@ packages: dependency: transitive description: name: node_preamble - sha256: "8ebdbaa3b96d5285d068f80772390d27c21e1fa10fb2df6627b1b9415043608d" + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" ordered_set: dependency: transitive description: name: ordered_set - sha256: "74b0454418f58c34c8e527d91fb1ef571297dbcd5d3b4e5f983dc884e39cdf85" + sha256: "3fedcc9121b3ba24c0a84f32da2989c42e36c159b73feadbc2f402dc55966b81" url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.0.1" package_config: dependency: transitive description: @@ -561,66 +561,66 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider: dependency: transitive description: name: path_provider - sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95 + sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" url: "https://pub.dev" source: hosted - version: "2.0.12" + version: "2.0.15" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e + sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" url: "https://pub.dev" source: hosted - version: "2.0.22" + version: "2.0.27" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74" + sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.2.4" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379 + sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 url: "https://pub.dev" source: hosted - version: "2.1.7" + version: "2.1.11" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: f0abc8ebd7253741f05488b4813d936b4d07c6bae3e86148a09e342ee4b08e76 + sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.0.6" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c + sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.7" petitparser: dependency: transitive description: name: petitparser - sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "5.4.0" platform: dependency: transitive description: @@ -633,18 +633,18 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: dbf0f707c78beedc9200146ad3cb0ab4d5da13c246336987be6940f026500d3a + sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.5" pointycastle: dependency: transitive description: name: pointycastle - sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346 + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" url: "https://pub.dev" source: hosted - version: "3.6.2" + version: "3.7.3" pool: dependency: transitive description: @@ -653,14 +653,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" - process: - dependency: transitive - description: - name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" - source: hosted - version: "4.2.4" provider: dependency: transitive description: @@ -673,18 +665,18 @@ packages: dependency: transitive description: name: pub_semver - sha256: "307de764d305289ff24ad257ad5c5793ce56d04947599ad68b3baa124105fc17" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" pubspec_parse: dependency: transitive description: name: pubspec_parse - sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.3" sharp_toggle_switch: dependency: "direct main" description: @@ -696,34 +688,34 @@ packages: dependency: transitive description: name: shelf - sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" shelf_packages_handler: dependency: transitive description: name: shelf_packages_handler - sha256: aef74dc9195746a384843102142ab65b6a4735bb3beea791e63527b88cc83306 + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" shelf_static: dependency: transitive description: name: shelf_static - sha256: e792b76b96a36d4a41b819da593aff4bdd413576b3ba6150df5d8d9996d2e74c + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" sky_engine: dependency: transitive description: flutter @@ -733,10 +725,10 @@ packages: dependency: transitive description: name: source_gen - sha256: c2bea18c95cfa0276a366270afaa2850b09b4a76db95d546f3d003dcc7011298 + sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 url: "https://pub.dev" source: hosted - version: "1.2.7" + version: "1.4.0" source_map_stack_trace: dependency: transitive description: @@ -749,10 +741,10 @@ packages: dependency: transitive description: name: source_maps - sha256: "490098075234dcedb83c5d949b4c93dad5e6b7702748de000be2b57b8e6b2427" + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" url: "https://pub.dev" source: hosted - version: "0.10.11" + version: "0.10.12" source_span: dependency: transitive description: @@ -797,10 +789,10 @@ packages: dependency: transitive description: name: synchronized - sha256: "33b31b6beb98100bf9add464a36a8dd03eb10c7a8cf15aeec535e9b054aaf04b" + sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.1.0" term_glyph: dependency: transitive description: @@ -813,26 +805,26 @@ packages: dependency: transitive description: name: test - sha256: a5fcd2d25eeadbb6589e80198a47d6a464ba3e2049da473943b8af9797900c2d + sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" url: "https://pub.dev" source: hosted - version: "1.22.0" + version: "1.24.1" test_api: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" test_core: dependency: transitive description: name: test_core - sha256: "0ef9755ec6d746951ba0aabe62f874b707690b5ede0fecc818b138fcc9b14888" + sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" url: "https://pub.dev" source: hosted - version: "0.4.20" + version: "0.5.1" tiled: dependency: transitive description: @@ -853,10 +845,10 @@ packages: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" uuid: dependency: transitive description: @@ -877,34 +869,34 @@ packages: dependency: "direct dev" description: name: very_good_analysis - sha256: ebc48c51db35beeeec8c414e32f7bd78e612bd7f5992ccb0d46e19edaeb40b08 + sha256: "5e4ea72d2a9188630f0dd8f120a541de730090ef8863243fedca8267a84508b8" url: "https://pub.dev" source: hosted - version: "4.0.0+1" + version: "5.0.0+1" vm_service: dependency: transitive description: name: vm_service - sha256: e7fb6c2282f7631712b69c19d1bff82f3767eea33a2321c14fa59ad67ea391c7 + sha256: ada49637c27973c183dad90beb6bd781eea4c9f5f955d35da172de0af7bd3440 url: "https://pub.dev" source: hosted - version: "9.4.0" + version: "11.8.0" watcher: dependency: transitive description: name: watcher - sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.1.0" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: ca49c0bc209c687b887f30527fb6a9d80040b072cc2990f34b9bec3e7663101b + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.4.0" webkit_inspection_protocol: dependency: transitive description: @@ -917,34 +909,34 @@ packages: dependency: transitive description: name: win32 - sha256: c9ebe7ee4ab0c2194e65d3a07d8c54c5d00bb001b76081c4a04cdb8448b59e46 + sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee url: "https://pub.dev" source: hosted - version: "3.1.3" + version: "5.0.5" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 + sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff url: "https://pub.dev" source: hosted - version: "0.2.0+3" + version: "1.0.1" xml: dependency: transitive description: name: xml - sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" url: "https://pub.dev" source: hosted - version: "6.2.2" + version: "6.3.0" yaml: dependency: transitive description: name: yaml - sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.2" sdks: - dart: ">=2.19.0 <3.0.0" - flutter: ">=3.7.0" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index 6925c41..d7a7dda 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,36 +4,36 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ">=2.19.0 <3.0.0" - flutter: ">=3.7.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: - bloc: ^8.1.1 + bloc: ^8.1.2 equatable: ^2.0.5 - flame: ^1.7.2 - flame_audio: ^1.4.0 + flame: ^1.8.1 + flame_audio: ^2.0.4 flame_behaviors: ^0.2.0 - flame_tiled: ^1.10.0 + flame_tiled: ^1.12.0 flutter: sdk: flutter - flutter_bloc: ^8.1.2 + flutter_bloc: ^8.1.3 flutter_localizations: sdk: flutter - freezed_annotation: ^2.2.0 - get_it: ^7.2.0 - intl: ^0.17.0 + freezed_annotation: ^2.4.1 + get_it: ^7.6.0 + intl: ^0.18.0 sharp_toggle_switch: path: ./packages/sharp_toggle_switch dev_dependencies: - bloc_test: ^9.1.1 - build_runner: ^2.3.3 - flame_test: ^1.10.0 + bloc_test: ^9.1.3 + build_runner: ^2.4.6 + flame_test: ^1.12.0 flutter_test: sdk: flutter - freezed: ^2.3.2 + freezed: ^2.4.1 mocktail: ^0.3.0 - very_good_analysis: ^4.0.0+1 + very_good_analysis: ^5.0.0+1 flutter: uses-material-design: true From 1a1ba145f820deadf7720ffe2affc8f21a472b42 Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Sat, 22 Jul 2023 18:48:48 +0200 Subject: [PATCH 2/6] feat: update flutter_version in main.yaml for github workflows --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 699d295..d4debe8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,4 +10,4 @@ jobs: uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1 with: flutter_channel: stable - flutter_version: 3.7.0 + flutter_version: 3.10.6 From 04f690b01cf1107ed20763a3683be5acd5a844ad Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Sat, 22 Jul 2023 22:09:26 +0200 Subject: [PATCH 3/6] feat: update the codebase based on the latest changes --- .../boy/behaviors/boy_air_resistance.dart | 6 +- .../behaviors/keyboard_moving_behavior.dart | 4 +- .../behaviors/star_colliding_behavior.dart | 2 +- lib/game/one_dungeon_game.dart | 107 +++++++++++------- lib/game/one_dungeon_game_x.dart | 51 +++++---- .../one_dungeon_audio_player.dart | 8 -- .../sharp_toggle_switch/analysis_options.yaml | 1 - .../widgets/start_game_listener_test.dart | 24 ++-- 8 files changed, 113 insertions(+), 90 deletions(-) diff --git a/lib/entities/boy/behaviors/boy_air_resistance.dart b/lib/entities/boy/behaviors/boy_air_resistance.dart index c701a61..7e6b14a 100644 --- a/lib/entities/boy/behaviors/boy_air_resistance.dart +++ b/lib/entities/boy/behaviors/boy_air_resistance.dart @@ -34,9 +34,11 @@ class BoyAirResistanceBehavior extends Behavior if (parent.position.x < parent.size.x / 2) { parent.velocity.x = 0; parent.position.x = parent.size.x / 2; - } else if (parent.position.x > gameRef.size[0] - parent.size.x / 2) { + } else if (parent.position.x > + gameRef.cameraComponent.visibleWorldRect.width - parent.size.x / 2) { parent.velocity.x = 0; - parent.position.x = gameRef.size[0] - parent.size.x / 2; + parent.position.x = + gameRef.cameraComponent.visibleWorldRect.width - parent.size.x / 2; } else { parent.position.x += parent.velocity.x * dt; } diff --git a/lib/entities/boy/behaviors/keyboard_moving_behavior.dart b/lib/entities/boy/behaviors/keyboard_moving_behavior.dart index 0f2d963..7f90681 100644 --- a/lib/entities/boy/behaviors/keyboard_moving_behavior.dart +++ b/lib/entities/boy/behaviors/keyboard_moving_behavior.dart @@ -32,7 +32,9 @@ class KeyboardMovingBehavior extends Behavior parent.velocity.x = -100; } else if (keysPressed.contains(rightKey) && !parent.isRightSideTouching && - parent.position.x < gameRef.size[0] - parent.size.x / 2) { + parent.position.x < + gameRef.cameraComponent.visibleWorldRect.width - + parent.size.x / 2) { parent.isWalking = true; parent.velocity.x = 100; } else { diff --git a/lib/entities/boy/behaviors/star_colliding_behavior.dart b/lib/entities/boy/behaviors/star_colliding_behavior.dart index 009be96..5164115 100644 --- a/lib/entities/boy/behaviors/star_colliding_behavior.dart +++ b/lib/entities/boy/behaviors/star_colliding_behavior.dart @@ -11,7 +11,7 @@ class StarCollidingBehavior extends CollisionBehavior Set intersectionPoints, Star other, ) async { - gameRef.remove(other); + gameRef.world.remove(other); gameRef.collectedStars++; await gameRef.audioPlayer.play(OneDungeonAudio.pickUpStar); diff --git a/lib/game/one_dungeon_game.dart b/lib/game/one_dungeon_game.dart index 346c2fb..a041b52 100644 --- a/lib/game/one_dungeon_game.dart +++ b/lib/game/one_dungeon_game.dart @@ -1,3 +1,4 @@ +import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flame/input.dart'; import 'package:flame_audio/flame_audio.dart'; @@ -28,8 +29,15 @@ class OneDungeonGame extends FlameGame score = 0, collectedStars = 0, focusNode = FocusNode(), + world = World(), super(); + /// Instance of [World]. + final World world; + + /// Instance of [CameraComponent]. + late final CameraComponent cameraComponent; + /// Instance of [OneDungeonAudioPlayer]. late final OneDungeonAudioPlayer audioPlayer; @@ -61,7 +69,8 @@ class OneDungeonGame extends FlameGame audioPlayer = di.injector(); FlameAudio.bgm.initialize(); - await _createWorld(); + await _createCameraAndWorld(); + await _createMap(); await _createEntities(); pauseEngine(); @@ -69,14 +78,26 @@ class OneDungeonGame extends FlameGame return super.onLoad(); } - Future _createWorld() async { - final map = await TiledComponent.load(GameMaps.kLeveOne, Vector2(16, 16)); - final mapHeight = 16.0 * map.tileMap.map.height; - final mapWidth = 16.0 * map.tileMap.map.width; + Future _createCameraAndWorld() async { + cameraComponent = CameraComponent.withFixedResolution( + world: world, + width: 16 * 80, + height: 16 * 40, + ); + + cameraComponent.viewfinder.zoom = 0.5; + cameraComponent.viewfinder.anchor = Anchor.topLeft; + + await addAll([cameraComponent, world]); + } + + Future _createMap() async { + final map = await TiledComponent.load(GameMaps.kLeveOne, Vector2.all(16)); - camera.viewport = FixedResolutionViewport(Vector2(mapWidth, mapHeight)); + // Add map to the world. + await world.add(map); - await add(map); + // Add map layers to the world. await _addGrounds(map); await _addGates(map); await _addTraps(map); @@ -85,58 +106,61 @@ class OneDungeonGame extends FlameGame Future _addGrounds(TiledComponent map) async { final obstacleGroup = map.tileMap.getLayer(GameMapLayers.kGroundLayer); - if (obstacleGroup != null) { - for (final obj in obstacleGroup.objects) { - await add( - Ground( - size: Vector2(obj.width, obj.height), - position: Vector2(obj.x, obj.y), - ), - ); - } + + if (obstacleGroup == null) return; + + for (final tiledObject in obstacleGroup.objects) { + await world.add( + Ground( + size: Vector2(tiledObject.width, tiledObject.height), + position: Vector2(tiledObject.x, tiledObject.y), + ), + ); } } Future _addGates(TiledComponent map) async { final obstacleGroup = map.tileMap.getLayer(GameMapLayers.kGateLayer); - if (obstacleGroup != null) { - for (final obj in obstacleGroup.objects) { - await add( - Gate( - size: Vector2(obj.width, obj.height), - position: Vector2(obj.x, obj.y), - ), - ); - } + + if (obstacleGroup == null) return; + + for (final tiledObject in obstacleGroup.objects) { + await world.add( + Gate( + size: Vector2(tiledObject.width, tiledObject.height), + position: Vector2(tiledObject.x, tiledObject.y), + ), + ); } } Future _addTraps(TiledComponent map) async { final obstacleGroup = map.tileMap.getLayer(GameMapLayers.kTrapLayer); - if (obstacleGroup != null) { - for (final obj in obstacleGroup.objects) { - await add( - Trap( - size: Vector2(obj.width, obj.height), - position: Vector2(obj.x, obj.y), - ), - ); - } + + if (obstacleGroup == null) return; + + for (final tiledObject in obstacleGroup.objects) { + await world.add( + Trap( + size: Vector2(tiledObject.width, tiledObject.height), + position: Vector2(tiledObject.x, tiledObject.y), + ), + ); } } Future _createEntities() async { await _addStars(); - await add(GameTime()); - await add(Elevator()); - await add(Boy.wasd()); + await world.add(GameTime()); + await world.add(Elevator()); + await world.add(Boy.wasd()); } Future _addStars() async { await Future.wait( - loadStars().map((loadableBuilder) => loadableBuilder()).toList(), + loadStars(world).map((loadableBuilder) => loadableBuilder()).toList(), ); } @@ -166,8 +190,11 @@ class OneDungeonGame extends FlameGame overlays.clear(); - removeAll(children); - await _createWorld(); + // Remove all children from the world. + world.removeAll(world.children); + + // Readd all children to the world. + await _createMap(); await _createEntities(); await audioPlayer.play(OneDungeonAudio.backgroundMusic); diff --git a/lib/game/one_dungeon_game_x.dart b/lib/game/one_dungeon_game_x.dart index 59003fd..20f6c25 100644 --- a/lib/game/one_dungeon_game_x.dart +++ b/lib/game/one_dungeon_game_x.dart @@ -1,3 +1,4 @@ +import 'package:flame/components.dart'; import 'package:flame/extensions.dart'; import 'package:one_dungeon/constants/constants.dart'; import 'package:one_dungeon/entities/entities.dart'; @@ -14,32 +15,32 @@ extension OneDungeonGameX on OneDungeonGame { ]; } - List Function()> loadStars() { + List Function()> loadStars(World world) { return [ - () async => add(Star(center: Vector2(350, 470))), - () async => add(Star(center: Vector2(665, 470))), - () async => add(Star(center: Vector2(805, 440))), - () async => add(Star(center: Vector2(950, 395))), - () async => add(Star(center: Vector2(1095, 380))), - () async => add(Star(center: Vector2(1260, 270))), - () async => add(Star(center: Vector2(1260, 110))), - () async => add(Star(center: Vector2(330, 130))), - () async => add(Star(center: Vector2(380, 140))), - () async => add(Star(center: Vector2(430, 150))), - () async => add(Star(center: Vector2(480, 160))), - () async => add(Star(center: Vector2(530, 150))), - () async => add(Star(center: Vector2(580, 140))), - () async => add(Star(center: Vector2(630, 130))), - () async => add(Star(center: Vector2(680, 140))), - () async => add(Star(center: Vector2(730, 150))), - () async => add(Star(center: Vector2(780, 160))), - () async => add(Star(center: Vector2(830, 170))), - () async => add(Star(center: Vector2(880, 160))), - () async => add(Star(center: Vector2(930, 150))), - () async => add(Star(center: Vector2(40, 120))), - () async => add(Star(center: Vector2(184, 150))), - () async => add(Star(center: Vector2(40, 240))), - () async => add(Star(center: Vector2(150, 355))), + () async => world.add(Star(center: Vector2(350, 470))), + () async => world.add(Star(center: Vector2(665, 470))), + () async => world.add(Star(center: Vector2(805, 440))), + () async => world.add(Star(center: Vector2(950, 395))), + () async => world.add(Star(center: Vector2(1095, 380))), + () async => world.add(Star(center: Vector2(1260, 270))), + () async => world.add(Star(center: Vector2(1260, 110))), + () async => world.add(Star(center: Vector2(330, 130))), + () async => world.add(Star(center: Vector2(380, 140))), + () async => world.add(Star(center: Vector2(430, 150))), + () async => world.add(Star(center: Vector2(480, 160))), + () async => world.add(Star(center: Vector2(530, 150))), + () async => world.add(Star(center: Vector2(580, 140))), + () async => world.add(Star(center: Vector2(630, 130))), + () async => world.add(Star(center: Vector2(680, 140))), + () async => world.add(Star(center: Vector2(730, 150))), + () async => world.add(Star(center: Vector2(780, 160))), + () async => world.add(Star(center: Vector2(830, 170))), + () async => world.add(Star(center: Vector2(880, 160))), + () async => world.add(Star(center: Vector2(930, 150))), + () async => world.add(Star(center: Vector2(40, 120))), + () async => world.add(Star(center: Vector2(184, 150))), + () async => world.add(Star(center: Vector2(40, 240))), + () async => world.add(Star(center: Vector2(150, 355))), ]; } } diff --git a/lib/one_dungeon_audio/one_dungeon_audio_player.dart b/lib/one_dungeon_audio/one_dungeon_audio_player.dart index 5401dae..27aac0d 100644 --- a/lib/one_dungeon_audio/one_dungeon_audio_player.dart +++ b/lib/one_dungeon_audio/one_dungeon_audio_player.dart @@ -117,35 +117,27 @@ class OneDungeonAudioPlayer { case OneDungeonAudio.backgroundMusic: if (!isBackgroundMusicActive) return; await _playBackgroundAudio(GameAssets.kBackgroudMusic, volume: 0.5); - break; case OneDungeonAudio.descending: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kDescendingSfx); - break; case OneDungeonAudio.jump: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kJumpSfx); - break; case OneDungeonAudio.landing: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kLandingSfx); - break; case OneDungeonAudio.pickUp: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kPickUpSfx); - break; case OneDungeonAudio.pickUpStar: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kPickUpStarSfx); - break; case OneDungeonAudio.select: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kSelectSfx); - break; case OneDungeonAudio.success: if (!isSfxActive) return; await _playSingleAudio(GameAssets.kSuccessSfx); - break; } } diff --git a/packages/sharp_toggle_switch/analysis_options.yaml b/packages/sharp_toggle_switch/analysis_options.yaml index aac4309..ae4c760 100644 --- a/packages/sharp_toggle_switch/analysis_options.yaml +++ b/packages/sharp_toggle_switch/analysis_options.yaml @@ -38,7 +38,6 @@ linter: unnecessary_getters_setters: true unnecessary_string_interpolations: true avoid_setters_without_getters: true - avoid_returning_null: true avoid_return_types_on_setters: true avoid_single_cascade_in_expression_statements: true avoid_types_on_closure_parameters: true diff --git a/test/start_game/widgets/start_game_listener_test.dart b/test/start_game/widgets/start_game_listener_test.dart index 0232a53..07ab587 100644 --- a/test/start_game/widgets/start_game_listener_test.dart +++ b/test/start_game/widgets/start_game_listener_test.dart @@ -37,8 +37,8 @@ void main() { testWidgets('renders StartGameListener', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, @@ -59,8 +59,8 @@ void main() { testWidgets('play works as expected', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, @@ -82,8 +82,8 @@ void main() { testWidgets('sound works as expected', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, @@ -106,8 +106,8 @@ void main() { testWidgets('language works as expected', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, @@ -130,8 +130,8 @@ void main() { testWidgets('how to play works as expected', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, @@ -154,8 +154,8 @@ void main() { testWidgets('about works as expected', (tester) async { await tester.runAsync(() async { await tester.pumpApp( - Stack( - children: const [ + const Stack( + children: [ OneDungeonGameLoadedView( initialActiveOverlays: [ OneDungeonGame.menuOverlay, From 35c2274ef3cd092d72e36959e2feabad14aba7b3 Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Sat, 22 Jul 2023 22:24:09 +0200 Subject: [PATCH 4/6] tests: update tests regard to world component --- .../behaviors/boy_air_resistance_test.dart | 24 +++++++++++++------ .../behaviors/boy_gravity_behavior_test.dart | 3 ++- .../danger_colliding_behavior_test.dart | 3 ++- .../elevator_colliding_behavior_test.dart | 15 ++++++++---- .../gate_colliding_behavior_test.dart | 3 ++- .../ground_colliding_behavior_test.dart | 15 ++++++++---- .../keyboard_moving_behavior_test.dart | 18 +++++++++----- .../star_colliding_behavior_test.dart | 14 ++++++----- test/entities/boy/boy_test.dart | 8 ++++--- .../elevator_moving_behavior_test.dart | 6 +++-- test/entities/elevator/elevator_test.dart | 8 ++++--- test/game/one_dungeon_game_test.dart | 4 ++-- 12 files changed, 79 insertions(+), 42 deletions(-) diff --git a/test/entities/boy/behaviors/boy_air_resistance_test.dart b/test/entities/boy/behaviors/boy_air_resistance_test.dart index 5c28861..1feab6a 100644 --- a/test/entities/boy/behaviors/boy_air_resistance_test.dart +++ b/test/entities/boy/behaviors/boy_air_resistance_test.dart @@ -36,7 +36,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.velocity.x, equals(10)); @@ -56,7 +57,7 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + await game.world.ensureAdd(boy); expect(boy.velocity.x, equals(-10)); @@ -77,7 +78,7 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + await game.world.ensureAdd(boy); expect(boy.position.x, equals(10)); @@ -93,18 +94,27 @@ void main() { (game) async { final boy = Boy.test( velocity: Vector2(10, 0), - center: Vector2(game.size[0], 0), + center: Vector2(game.cameraComponent.visibleWorldRect.width, 0), behavior: boyAirResistanceBehavior, ); await game.ready(); - await game.ensureAdd(boy); - expect(boy.position.x, equals(game.size[0])); + await game.world.ensureAdd(boy); + + expect( + boy.position.x, + equals(game.cameraComponent.visibleWorldRect.width), + ); game.update(1); - expect(boy.position.x, equals(game.size[0] - (boy.size.x / 2))); + expect( + boy.position.x, + equals( + game.cameraComponent.visibleWorldRect.width - (boy.size.x / 2), + ), + ); }, ); }); diff --git a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart index 286323f..ccf8ef5 100644 --- a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart +++ b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart @@ -37,7 +37,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); boy.isBottomTouching = false; game.update(1); diff --git a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart index 19752ec..1474c97 100644 --- a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart @@ -60,7 +60,8 @@ void main() { (context, game) => const SizedBox(), ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.velocity.x, equals(10)); expect(boy.velocity.y, equals(20)); diff --git a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart index 0e1fdec..6812713 100644 --- a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart @@ -36,7 +36,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); boy.isBottomTouching = false; elevatorCollidingBehavior @@ -56,7 +57,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isTopTouching, isFalse); @@ -77,7 +79,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isLeftSideTouching, isFalse); expect(boy.isRightSideTouching, isFalse); @@ -101,7 +104,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isLeftSideTouching, isFalse); expect(boy.isRightSideTouching, isFalse); @@ -126,7 +130,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isBottomTouching, isFalse); diff --git a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart index 4625c30..26fab49 100644 --- a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart @@ -59,7 +59,8 @@ void main() { (context, game) => const SizedBox(), ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); gateCollidingBehavior .onCollisionStart({Vector2(0, 0), Vector2(10, 0)}, _MockGate()); diff --git a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart index abd91c0..f27c8d1 100644 --- a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart @@ -40,7 +40,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); boy.isBottomTouching = false; groundCollidingBehavior @@ -60,7 +61,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isTopTouching, isFalse); @@ -81,7 +83,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isLeftSideTouching, isFalse); expect(boy.isRightSideTouching, isFalse); @@ -105,7 +108,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isLeftSideTouching, isFalse); expect(boy.isRightSideTouching, isFalse); @@ -130,7 +134,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.isBottomTouching, isFalse); diff --git a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart index 6b399ce..1999d57 100644 --- a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart +++ b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart @@ -70,7 +70,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final keysPressed = {LogicalKeyboardKey.arrowUp}; @@ -92,7 +93,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final keysPressed = {LogicalKeyboardKey.arrowRight}; @@ -114,7 +116,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final keysPressed = {LogicalKeyboardKey.arrowLeft}; @@ -136,7 +139,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final leftKeysPressed = {LogicalKeyboardKey.arrowLeft}; @@ -163,7 +167,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final keysPressed = {}; @@ -185,7 +190,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); final event = _RawKeyEvent(); final keysPressed = {LogicalKeyboardKey.arrowUp}; diff --git a/test/entities/boy/behaviors/star_colliding_behavior_test.dart b/test/entities/boy/behaviors/star_colliding_behavior_test.dart index b500a08..8edc6fa 100644 --- a/test/entities/boy/behaviors/star_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/star_colliding_behavior_test.dart @@ -57,8 +57,9 @@ void main() { ); await game.ready(); - await game.ensureAdd(star); - await game.ensureAdd(boy); + + await game.world.ensureAdd(star); + await game.world.ensureAdd(boy); final collectedStars = game.collectedStars; @@ -85,16 +86,17 @@ void main() { ); await game.ready(); - await game.ensureAdd(star); - await game.ensureAdd(boy); - expect(game.children.contains(star), isTrue); + await game.world.ensureAdd(star); + await game.world.ensureAdd(boy); + + expect(game.world.children.contains(star), isTrue); await starCollidingBehavior .onCollisionStart({Vector2(0, 0), Vector2(10, 0)}, star); game.update(1); - expect(game.children.contains(star), isFalse); + expect(game.world.children.contains(star), isFalse); }, ); }); diff --git a/test/entities/boy/boy_test.dart b/test/entities/boy/boy_test.dart index 545c583..059ee38 100644 --- a/test/entities/boy/boy_test.dart +++ b/test/entities/boy/boy_test.dart @@ -27,9 +27,10 @@ void main() { final boy = Boy.wasd(); await game.ready(); - await game.ensureAdd(boy); - expect(game.contains(boy), isTrue); + await game.world.ensureAdd(boy); + + expect(game.world.contains(boy), isTrue); }, ); @@ -40,7 +41,8 @@ void main() { final boy = Boy.arrows(center: Vector2.zero()); await game.ready(); - await game.ensureAdd(boy); + + await game.world.ensureAdd(boy); expect(boy.position, closeToVector(Vector2(0, 0))); }, diff --git a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart index c9bc138..a3cc85c 100644 --- a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart +++ b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart @@ -37,7 +37,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(elevator); + + await game.world.ensureAdd(elevator); elevatorMovingBehavior.isGoingDown = true; @@ -58,7 +59,8 @@ void main() { ); await game.ready(); - await game.ensureAdd(elevator); + + await game.world.ensureAdd(elevator); elevatorMovingBehavior.isGoingDown = false; diff --git a/test/entities/elevator/elevator_test.dart b/test/entities/elevator/elevator_test.dart index 8f07723..8fab5ae 100644 --- a/test/entities/elevator/elevator_test.dart +++ b/test/entities/elevator/elevator_test.dart @@ -27,9 +27,10 @@ void main() { final elevator = Elevator.test(); await game.ready(); - await game.ensureAdd(elevator); - expect(game.contains(elevator), isTrue); + await game.world.ensureAdd(elevator); + + expect(game.world.contains(elevator), isTrue); }, ); @@ -40,7 +41,8 @@ void main() { final elevator = Elevator.test(center: Vector2.zero()); await game.ready(); - await game.ensureAdd(elevator); + + await game.world.ensureAdd(elevator); expect(elevator.position, closeToVector(Vector2(0, 0))); }, diff --git a/test/game/one_dungeon_game_test.dart b/test/game/one_dungeon_game_test.dart index ba14622..2d2b2bb 100644 --- a/test/game/one_dungeon_game_test.dart +++ b/test/game/one_dungeon_game_test.dart @@ -88,7 +88,7 @@ void main() { await game.ready(); expect( - game.children.whereType().length, + game.world.children.whereType().length, equals(1), ); }, @@ -102,7 +102,7 @@ void main() { (game) async { await game.ready(); - final boy = game.children.whereType(); + final boy = game.world.children.whereType(); expect( boy.first.hasBehavior(), From 92fd8962a49e0f960d568027d3e06b2307e7179a Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Sun, 23 Jul 2023 16:41:11 +0200 Subject: [PATCH 5/6] test: update tests for full cover --- lib/game/one_dungeon_game.dart | 8 +++++++- lib/injector.dart | 8 +++++++- .../one_dungeon_audio_player.dart | 16 ++++++++-------- test/about/widgets/about_game_dialog_test.dart | 3 +++ test/app/view/app_test.dart | 15 +++------------ .../cubit/assets_manager_cubit_test.dart | 12 +----------- test/assets_manager/view/loading_page_test.dart | 2 +- .../boy/behaviors/boy_air_resistance_test.dart | 5 ++++- .../boy/behaviors/boy_gravity_behavior_test.dart | 3 +++ .../danger_colliding_behavior_test.dart | 12 +----------- .../elevator_colliding_behavior_test.dart | 3 +++ .../behaviors/gate_colliding_behavior_test.dart | 12 +----------- .../ground_colliding_behavior_test.dart | 3 +++ .../behaviors/keyboard_moving_behavior_test.dart | 3 +++ .../behaviors/star_colliding_behavior_test.dart | 12 +----------- test/entities/boy/boy_test.dart | 3 +++ .../behaviors/elevator_moving_behavior_test.dart | 3 +++ test/entities/elevator/elevator_test.dart | 3 +++ test/game/one_dungeon_game_test.dart | 3 +++ test/game/view/one_dungeon_game_page_test.dart | 5 ++++- .../widgets/game_over_menu_overlay_test.dart | 13 +++---------- test/game/view/widgets/menu_button_test.dart | 13 +------------ test/game/view/widgets/menu_overlay_test.dart | 3 +++ test/helpers/helpers.dart | 1 + test/helpers/test_audio_player.dart | 11 +++++++++++ test/how_to_play/widgets/how_to_dialog_test.dart | 3 +++ .../one_dungeon_audio_player_test.dart | 2 +- .../widgets/sound_settings_dialog_test.dart | 13 +++---------- .../widgets/start_game_listener_test.dart | 13 +------------ 29 files changed, 92 insertions(+), 114 deletions(-) create mode 100644 test/helpers/test_audio_player.dart diff --git a/lib/game/one_dungeon_game.dart b/lib/game/one_dungeon_game.dart index a041b52..a6e39cb 100644 --- a/lib/game/one_dungeon_game.dart +++ b/lib/game/one_dungeon_game.dart @@ -1,8 +1,11 @@ +import 'dart:io'; + import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flame/input.dart'; import 'package:flame_audio/flame_audio.dart'; import 'package:flame_tiled/flame_tiled.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:one_dungeon/components/components.dart'; @@ -67,7 +70,10 @@ class OneDungeonGame extends FlameGame @override Future? onLoad() async { audioPlayer = di.injector(); - FlameAudio.bgm.initialize(); + + if (kIsWeb || !Platform.environment.containsKey('FLUTTER_TEST')) { + FlameAudio.bgm.initialize(); + } await _createCameraAndWorld(); await _createMap(); diff --git a/lib/injector.dart b/lib/injector.dart index 769f592..910cb40 100644 --- a/lib/injector.dart +++ b/lib/injector.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; import 'package:get_it/get_it.dart'; import 'package:one_dungeon/assets_manager/assets_manager.dart'; import 'package:one_dungeon/game/game.dart'; @@ -7,8 +10,11 @@ import 'package:one_dungeon/start_game/start_game.dart'; final injector = GetIt.instance; Future initializeDependencies() async { + if (kIsWeb || !Platform.environment.containsKey('FLUTTER_TEST')) { + injector.registerSingleton(OneDungeonAudioPlayer()); + } + injector - ..registerSingleton(OneDungeonAudioPlayer()) ..registerSingleton(OneDungeonGame()) ..registerFactory( () => AssetsManagerCubit( diff --git a/lib/one_dungeon_audio/one_dungeon_audio_player.dart b/lib/one_dungeon_audio/one_dungeon_audio_player.dart index 27aac0d..48316a4 100644 --- a/lib/one_dungeon_audio/one_dungeon_audio_player.dart +++ b/lib/one_dungeon_audio/one_dungeon_audio_player.dart @@ -116,28 +116,28 @@ class OneDungeonAudioPlayer { switch (audio) { case OneDungeonAudio.backgroundMusic: if (!isBackgroundMusicActive) return; - await _playBackgroundAudio(GameAssets.kBackgroudMusic, volume: 0.5); + return _playBackgroundAudio(GameAssets.kBackgroudMusic, volume: 0.5); case OneDungeonAudio.descending: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kDescendingSfx); + return _playSingleAudio(GameAssets.kDescendingSfx); case OneDungeonAudio.jump: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kJumpSfx); + return _playSingleAudio(GameAssets.kJumpSfx); case OneDungeonAudio.landing: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kLandingSfx); + return _playSingleAudio(GameAssets.kLandingSfx); case OneDungeonAudio.pickUp: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kPickUpSfx); + return _playSingleAudio(GameAssets.kPickUpSfx); case OneDungeonAudio.pickUpStar: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kPickUpStarSfx); + return _playSingleAudio(GameAssets.kPickUpStarSfx); case OneDungeonAudio.select: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kSelectSfx); + return _playSingleAudio(GameAssets.kSelectSfx); case OneDungeonAudio.success: if (!isSfxActive) return; - await _playSingleAudio(GameAssets.kSuccessSfx); + return _playSingleAudio(GameAssets.kSuccessSfx); } } diff --git a/test/about/widgets/about_game_dialog_test.dart b/test/about/widgets/about_game_dialog_test.dart index 9daae99..7134aa5 100644 --- a/test/about/widgets/about_game_dialog_test.dart +++ b/test/about/widgets/about_game_dialog_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/about/about.dart'; import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; @@ -9,6 +10,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/app/view/app_test.dart b/test/app/view/app_test.dart index d325736..b693b45 100644 --- a/test/app/view/app_test.dart +++ b/test/app/view/app_test.dart @@ -4,24 +4,15 @@ import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/injector.dart' as di; import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; +import '../../helpers/helpers.dart'; + void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; - setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/assets_manager/cubit/assets_manager_cubit_test.dart b/test/assets_manager/cubit/assets_manager_cubit_test.dart index ab0af8f..6259412 100644 --- a/test/assets_manager/cubit/assets_manager_cubit_test.dart +++ b/test/assets_manager/cubit/assets_manager_cubit_test.dart @@ -1,27 +1,17 @@ import 'package:bloc_test/bloc_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/assets_manager/assets_manager.dart'; -import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late TestGame game; - late OneDungeonAudioPlayer audioPlayer; late AssetsManagerCubit assetsManagerCubit; setUp(() async { - game = TestGame(); - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); assetsManagerCubit = - AssetsManagerCubit(game: game, audioPlayer: audioPlayer); + AssetsManagerCubit(game: TestGame(), audioPlayer: TestAudioPlayer()); }); tearDown(() { diff --git a/test/assets_manager/view/loading_page_test.dart b/test/assets_manager/view/loading_page_test.dart index 3acfb36..4d11df7 100644 --- a/test/assets_manager/view/loading_page_test.dart +++ b/test/assets_manager/view/loading_page_test.dart @@ -11,7 +11,7 @@ class _MockAssetsManagerCubit extends MockCubit implements AssetsManagerCubit {} void main() { - late _MockAssetsManagerCubit mockAssetsManagerCubit; + late AssetsManagerCubit mockAssetsManagerCubit; setUpAll(() async { mockAssetsManagerCubit = _MockAssetsManagerCubit(); diff --git a/test/entities/boy/behaviors/boy_air_resistance_test.dart b/test/entities/boy/behaviors/boy_air_resistance_test.dart index 1feab6a..8e2b3d9 100644 --- a/test/entities/boy/behaviors/boy_air_resistance_test.dart +++ b/test/entities/boy/behaviors/boy_air_resistance_test.dart @@ -5,8 +5,9 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; -import '../../../helpers/test_game.dart'; +import '../../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -18,6 +19,8 @@ void main() { }); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart index ccf8ef5..d758d37 100644 --- a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart +++ b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart @@ -5,6 +5,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -14,6 +15,8 @@ void main() { late BoyGravityBehavior boyGravityBehavior; setUp(() { + di.injector.registerSingleton(TestAudioPlayer()); + boyGravityBehavior = BoyGravityBehavior(); }); diff --git a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart index 1474c97..79a280f 100644 --- a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart @@ -18,7 +18,6 @@ class _MockDanger extends Mock implements Danger {} void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; late DangerCollidingBehavior dangerCollidingBehavior; setUp(() { @@ -26,18 +25,9 @@ void main() { }); setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart index 6812713..e1d6603 100644 --- a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart @@ -5,6 +5,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -18,6 +19,8 @@ void main() { }); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart index 26fab49..4c64fd3 100644 --- a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart @@ -18,7 +18,6 @@ class _MockGate extends Mock implements Gate {} void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; late GateCollidingBehavior gateCollidingBehavior; setUp(() { @@ -26,18 +25,9 @@ void main() { }); setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart index f27c8d1..e4fa486 100644 --- a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart @@ -7,6 +7,7 @@ import 'package:mocktail/mocktail.dart'; import 'package:one_dungeon/components/components.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -22,6 +23,8 @@ void main() { }); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart index 1999d57..af1497e 100644 --- a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart +++ b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart @@ -8,6 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -36,6 +37,8 @@ void main() { }); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/boy/behaviors/star_colliding_behavior_test.dart b/test/entities/boy/behaviors/star_colliding_behavior_test.dart index 8edc6fa..2b3690a 100644 --- a/test/entities/boy/behaviors/star_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/star_colliding_behavior_test.dart @@ -14,7 +14,6 @@ import '../../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; late StarCollidingBehavior starCollidingBehavior; setUp(() { @@ -22,18 +21,9 @@ void main() { }); setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/entities/boy/boy_test.dart b/test/entities/boy/boy_test.dart index 059ee38..d075f18 100644 --- a/test/entities/boy/boy_test.dart +++ b/test/entities/boy/boy_test.dart @@ -5,6 +5,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; @@ -12,6 +13,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart index a3cc85c..bd5462e 100644 --- a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart +++ b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart @@ -5,6 +5,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -18,6 +19,8 @@ void main() { }); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/entities/elevator/elevator_test.dart b/test/entities/elevator/elevator_test.dart index 8fab5ae..cec1754 100644 --- a/test/entities/elevator/elevator_test.dart +++ b/test/entities/elevator/elevator_test.dart @@ -5,6 +5,7 @@ import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; @@ -12,6 +13,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/game/one_dungeon_game_test.dart b/test/game/one_dungeon_game_test.dart index 2d2b2bb..01f25c1 100644 --- a/test/game/one_dungeon_game_test.dart +++ b/test/game/one_dungeon_game_test.dart @@ -9,6 +9,7 @@ import 'package:one_dungeon/components/components.dart'; import 'package:one_dungeon/entities/entities.dart'; import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../helpers/helpers.dart'; @@ -27,6 +28,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/game/view/one_dungeon_game_page_test.dart b/test/game/view/one_dungeon_game_page_test.dart index b7dbb03..4975a52 100644 --- a/test/game/view/one_dungeon_game_page_test.dart +++ b/test/game/view/one_dungeon_game_page_test.dart @@ -5,6 +5,7 @@ import 'package:mocktail/mocktail.dart'; import 'package:one_dungeon/assets_manager/assets_manager.dart'; import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; @@ -14,9 +15,11 @@ class _MockAssetsManagerCubit extends MockCubit void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late _MockAssetsManagerCubit mockAssetsManagerCubit; + late AssetsManagerCubit mockAssetsManagerCubit; setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/game/view/widgets/game_over_menu_overlay_test.dart b/test/game/view/widgets/game_over_menu_overlay_test.dart index 5011885..41c26c5 100644 --- a/test/game/view/widgets/game_over_menu_overlay_test.dart +++ b/test/game/view/widgets/game_over_menu_overlay_test.dart @@ -12,17 +12,10 @@ void main() { late OneDungeonAudioPlayer audioPlayer; setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); - await di.initializeDependencies(); - - await di.injector.unregister(); - + audioPlayer = TestAudioPlayer(); di.injector.registerSingleton(audioPlayer); + + await di.initializeDependencies(); }); tearDownAll(() async { diff --git a/test/game/view/widgets/menu_button_test.dart b/test/game/view/widgets/menu_button_test.dart index ed3b40b..525f7af 100644 --- a/test/game/view/widgets/menu_button_test.dart +++ b/test/game/view/widgets/menu_button_test.dart @@ -10,21 +10,10 @@ import '../../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; - setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/game/view/widgets/menu_overlay_test.dart b/test/game/view/widgets/menu_overlay_test.dart index 6ecf0c2..9e042f7 100644 --- a/test/game/view/widgets/menu_overlay_test.dart +++ b/test/game/view/widgets/menu_overlay_test.dart @@ -1,6 +1,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; @@ -8,6 +9,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/helpers/helpers.dart b/test/helpers/helpers.dart index f80b105..6b4bca9 100644 --- a/test/helpers/helpers.dart +++ b/test/helpers/helpers.dart @@ -1,2 +1,3 @@ export 'pump_app.dart'; +export 'test_audio_player.dart'; export 'test_game.dart'; diff --git a/test/helpers/test_audio_player.dart b/test/helpers/test_audio_player.dart new file mode 100644 index 0000000..917ce77 --- /dev/null +++ b/test/helpers/test_audio_player.dart @@ -0,0 +1,11 @@ +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; + +class TestAudioPlayer extends OneDungeonAudioPlayer { + TestAudioPlayer() + : super.test( + playBackgroundAudio: (_, {double? volume}) async {}, + stopBackgroundAudio: () async {}, + playSingleAudio: (_, {double? volume}) async {}, + preCacheSingleAudio: (_) async {}, + ); +} diff --git a/test/how_to_play/widgets/how_to_dialog_test.dart b/test/how_to_play/widgets/how_to_dialog_test.dart index 7749053..60462f9 100644 --- a/test/how_to_play/widgets/how_to_dialog_test.dart +++ b/test/how_to_play/widgets/how_to_dialog_test.dart @@ -2,6 +2,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:one_dungeon/game/game.dart'; import 'package:one_dungeon/how_to_play/how_to_play.dart'; import 'package:one_dungeon/injector.dart' as di; +import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; @@ -9,6 +10,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUpAll(() async { + di.injector.registerSingleton(TestAudioPlayer()); + await di.initializeDependencies(); }); diff --git a/test/one_dungeon_audio/one_dungeon_audio_player_test.dart b/test/one_dungeon_audio/one_dungeon_audio_player_test.dart index 3c0c860..59102a6 100644 --- a/test/one_dungeon_audio/one_dungeon_audio_player_test.dart +++ b/test/one_dungeon_audio/one_dungeon_audio_player_test.dart @@ -16,7 +16,7 @@ class _MockAudioPlayerTester extends Mock implements _AudioPlayerTester {} void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late _MockAudioPlayerTester mockAudioPlayerTester; + late _AudioPlayerTester mockAudioPlayerTester; late OneDungeonAudioPlayer audioPlayer; setUpAll(() { diff --git a/test/sound/widgets/sound_settings_dialog_test.dart b/test/sound/widgets/sound_settings_dialog_test.dart index 03bd7c8..df51c26 100644 --- a/test/sound/widgets/sound_settings_dialog_test.dart +++ b/test/sound/widgets/sound_settings_dialog_test.dart @@ -13,17 +13,10 @@ void main() { late OneDungeonAudioPlayer audioPlayer; setUpAll(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); - await di.initializeDependencies(); - - await di.injector.unregister(); - + audioPlayer = TestAudioPlayer(); di.injector.registerSingleton(audioPlayer); + + await di.initializeDependencies(); }); tearDownAll(() async { diff --git a/test/start_game/widgets/start_game_listener_test.dart b/test/start_game/widgets/start_game_listener_test.dart index 07ab587..c68eb31 100644 --- a/test/start_game/widgets/start_game_listener_test.dart +++ b/test/start_game/widgets/start_game_listener_test.dart @@ -12,21 +12,10 @@ import '../../helpers/helpers.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - late OneDungeonAudioPlayer audioPlayer; - setUp(() async { - audioPlayer = OneDungeonAudioPlayer.test( - playBackgroundAudio: (_, {double? volume}) async {}, - stopBackgroundAudio: () async {}, - playSingleAudio: (_, {double? volume}) async {}, - preCacheSingleAudio: (_) async {}, - ); + di.injector.registerSingleton(TestAudioPlayer()); await di.initializeDependencies(); - - await di.injector.unregister(); - - di.injector.registerSingleton(audioPlayer); }); tearDown(() async { From d563a8514de9ca418b21fb1fbf4fd463d1a58540 Mon Sep 17 00:00:00 2001 From: Bulent Baris Kilic Date: Mon, 24 Jul 2023 00:25:17 +0200 Subject: [PATCH 6/6] test: update tests for full coverage --- lib/game/one_dungeon_game.dart | 7 +------ lib/injector.dart | 8 +------- lib/one_dungeon_audio/one_dungeon_audio_player.dart | 8 ++++---- test/about/widgets/about_game_dialog_test.dart | 6 +++--- test/app/view/app_test.dart | 6 +++--- test/assets_manager/view/loading_page_test.dart | 2 ++ .../boy/behaviors/boy_air_resistance_test.dart | 6 +++--- .../boy/behaviors/boy_gravity_behavior_test.dart | 6 +++--- .../behaviors/danger_colliding_behavior_test.dart | 6 +++--- .../behaviors/elevator_colliding_behavior_test.dart | 6 +++--- .../boy/behaviors/gate_colliding_behavior_test.dart | 6 +++--- .../behaviors/ground_colliding_behavior_test.dart | 6 +++--- .../behaviors/keyboard_moving_behavior_test.dart | 6 +++--- .../boy/behaviors/star_colliding_behavior_test.dart | 6 +++--- test/entities/boy/boy_test.dart | 6 +++--- .../behaviors/elevator_moving_behavior_test.dart | 6 +++--- test/entities/elevator/elevator_test.dart | 6 +++--- test/game/one_dungeon_game_test.dart | 6 +++--- test/game/view/one_dungeon_game_page_test.dart | 6 +++--- .../view/widgets/game_over_menu_overlay_test.dart | 6 +++--- test/game/view/widgets/menu_button_test.dart | 6 +++--- test/game/view/widgets/menu_overlay_test.dart | 6 +++--- test/helpers/helpers.dart | 1 + test/helpers/test_widgets_binding.dart | 13 +++++++++++++ test/how_to_play/widgets/how_to_dialog_test.dart | 6 +++--- .../one_dungeon_audio_player_test.dart | 8 +++++++- test/sound/widgets/sound_settings_dialog_test.dart | 6 +++--- .../widgets/start_game_listener_test.dart | 6 +++--- 28 files changed, 92 insertions(+), 81 deletions(-) create mode 100644 test/helpers/test_widgets_binding.dart diff --git a/lib/game/one_dungeon_game.dart b/lib/game/one_dungeon_game.dart index a6e39cb..23bb0f9 100644 --- a/lib/game/one_dungeon_game.dart +++ b/lib/game/one_dungeon_game.dart @@ -1,11 +1,8 @@ -import 'dart:io'; - import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flame/input.dart'; import 'package:flame_audio/flame_audio.dart'; import 'package:flame_tiled/flame_tiled.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:one_dungeon/components/components.dart'; @@ -71,9 +68,7 @@ class OneDungeonGame extends FlameGame Future? onLoad() async { audioPlayer = di.injector(); - if (kIsWeb || !Platform.environment.containsKey('FLUTTER_TEST')) { - FlameAudio.bgm.initialize(); - } + FlameAudio.bgm.initialize(); await _createCameraAndWorld(); await _createMap(); diff --git a/lib/injector.dart b/lib/injector.dart index 910cb40..769f592 100644 --- a/lib/injector.dart +++ b/lib/injector.dart @@ -1,6 +1,3 @@ -import 'dart:io'; - -import 'package:flutter/foundation.dart'; import 'package:get_it/get_it.dart'; import 'package:one_dungeon/assets_manager/assets_manager.dart'; import 'package:one_dungeon/game/game.dart'; @@ -10,11 +7,8 @@ import 'package:one_dungeon/start_game/start_game.dart'; final injector = GetIt.instance; Future initializeDependencies() async { - if (kIsWeb || !Platform.environment.containsKey('FLUTTER_TEST')) { - injector.registerSingleton(OneDungeonAudioPlayer()); - } - injector + ..registerSingleton(OneDungeonAudioPlayer()) ..registerSingleton(OneDungeonGame()) ..registerFactory( () => AssetsManagerCubit( diff --git a/lib/one_dungeon_audio/one_dungeon_audio_player.dart b/lib/one_dungeon_audio/one_dungeon_audio_player.dart index 48316a4..55ba658 100644 --- a/lib/one_dungeon_audio/one_dungeon_audio_player.dart +++ b/lib/one_dungeon_audio/one_dungeon_audio_player.dart @@ -101,13 +101,13 @@ class OneDungeonAudioPlayer { bool isSfxActive; - PlayBackgroundAudio _playBackgroundAudio; + final PlayBackgroundAudio _playBackgroundAudio; - StopBackgroundAudio _stopBackgroundAudio; + final StopBackgroundAudio _stopBackgroundAudio; - PlaySingleAudio _playSingleAudio; + final PlaySingleAudio _playSingleAudio; - PreCacheSingleAudio preCacheSingleAudio; + final PreCacheSingleAudio preCacheSingleAudio; /// Plays the received audio. Future play(OneDungeonAudio audio) async { diff --git a/test/about/widgets/about_game_dialog_test.dart b/test/about/widgets/about_game_dialog_test.dart index 7134aa5..c23d139 100644 --- a/test/about/widgets/about_game_dialog_test.dart +++ b/test/about/widgets/about_game_dialog_test.dart @@ -7,12 +7,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/app/view/app_test.dart b/test/app/view/app_test.dart index b693b45..03c1ab1 100644 --- a/test/app/view/app_test.dart +++ b/test/app/view/app_test.dart @@ -7,12 +7,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/assets_manager/view/loading_page_test.dart b/test/assets_manager/view/loading_page_test.dart index 4d11df7..4be63ca 100644 --- a/test/assets_manager/view/loading_page_test.dart +++ b/test/assets_manager/view/loading_page_test.dart @@ -11,6 +11,8 @@ class _MockAssetsManagerCubit extends MockCubit implements AssetsManagerCubit {} void main() { + TestWidgetsBinding.ensureInitialized(); + late AssetsManagerCubit mockAssetsManagerCubit; setUpAll(() async { diff --git a/test/entities/boy/behaviors/boy_air_resistance_test.dart b/test/entities/boy/behaviors/boy_air_resistance_test.dart index 8e2b3d9..2b283d7 100644 --- a/test/entities/boy/behaviors/boy_air_resistance_test.dart +++ b/test/entities/boy/behaviors/boy_air_resistance_test.dart @@ -10,7 +10,7 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late BoyAirResistanceBehavior boyAirResistanceBehavior; @@ -19,9 +19,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart index d758d37..0340aa0 100644 --- a/test/entities/boy/behaviors/boy_gravity_behavior_test.dart +++ b/test/entities/boy/behaviors/boy_gravity_behavior_test.dart @@ -10,18 +10,18 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late BoyGravityBehavior boyGravityBehavior; setUp(() { - di.injector.registerSingleton(TestAudioPlayer()); - boyGravityBehavior = BoyGravityBehavior(); }); setUpAll(() async { await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart index 79a280f..160454d 100644 --- a/test/entities/boy/behaviors/danger_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/danger_colliding_behavior_test.dart @@ -16,7 +16,7 @@ import '../../../helpers/helpers.dart'; class _MockDanger extends Mock implements Danger {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late DangerCollidingBehavior dangerCollidingBehavior; @@ -25,9 +25,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart index e1d6603..a939ded 100644 --- a/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/elevator_colliding_behavior_test.dart @@ -10,7 +10,7 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late ElevatorCollidingBehavior elevatorCollidingBehavior; @@ -19,9 +19,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart index 4c64fd3..7f7c4de 100644 --- a/test/entities/boy/behaviors/gate_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/gate_colliding_behavior_test.dart @@ -16,7 +16,7 @@ import '../../../helpers/helpers.dart'; class _MockGate extends Mock implements Gate {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late GateCollidingBehavior gateCollidingBehavior; @@ -25,9 +25,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart index e4fa486..8fe0227 100644 --- a/test/entities/boy/behaviors/ground_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/ground_colliding_behavior_test.dart @@ -14,7 +14,7 @@ import '../../../helpers/helpers.dart'; class _MockGround extends Mock implements Ground {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late GroundCollidingBehavior groundCollidingBehavior; @@ -23,9 +23,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart index af1497e..19e1e68 100644 --- a/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart +++ b/test/entities/boy/behaviors/keyboard_moving_behavior_test.dart @@ -24,7 +24,7 @@ class _RawKeyEvent extends Mock implements RawKeyEvent {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late KeyboardMovingBehavior keyboardMovingBehavior; @@ -37,9 +37,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/behaviors/star_colliding_behavior_test.dart b/test/entities/boy/behaviors/star_colliding_behavior_test.dart index 2b3690a..a35cbc1 100644 --- a/test/entities/boy/behaviors/star_colliding_behavior_test.dart +++ b/test/entities/boy/behaviors/star_colliding_behavior_test.dart @@ -12,7 +12,7 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late StarCollidingBehavior starCollidingBehavior; @@ -21,9 +21,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/boy/boy_test.dart b/test/entities/boy/boy_test.dart index d075f18..8d88d1e 100644 --- a/test/entities/boy/boy_test.dart +++ b/test/entities/boy/boy_test.dart @@ -10,12 +10,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart index bd5462e..dca0b04 100644 --- a/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart +++ b/test/entities/elevator/behaviors/elevator_moving_behavior_test.dart @@ -10,7 +10,7 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late ElevatorMovingBehavior elevatorMovingBehavior; @@ -19,9 +19,9 @@ void main() { }); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/entities/elevator/elevator_test.dart b/test/entities/elevator/elevator_test.dart index cec1754..d1ae99a 100644 --- a/test/entities/elevator/elevator_test.dart +++ b/test/entities/elevator/elevator_test.dart @@ -10,12 +10,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/game/one_dungeon_game_test.dart b/test/game/one_dungeon_game_test.dart index 01f25c1..e4bf33d 100644 --- a/test/game/one_dungeon_game_test.dart +++ b/test/game/one_dungeon_game_test.dart @@ -25,12 +25,12 @@ class _RawKeyEvent extends Mock implements RawKeyEvent {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/game/view/one_dungeon_game_page_test.dart b/test/game/view/one_dungeon_game_page_test.dart index 4975a52..4e691e5 100644 --- a/test/game/view/one_dungeon_game_page_test.dart +++ b/test/game/view/one_dungeon_game_page_test.dart @@ -13,14 +13,14 @@ class _MockAssetsManagerCubit extends MockCubit implements AssetsManagerCubit {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late AssetsManagerCubit mockAssetsManagerCubit; setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); setUp(() async { diff --git a/test/game/view/widgets/game_over_menu_overlay_test.dart b/test/game/view/widgets/game_over_menu_overlay_test.dart index 41c26c5..7c84970 100644 --- a/test/game/view/widgets/game_over_menu_overlay_test.dart +++ b/test/game/view/widgets/game_over_menu_overlay_test.dart @@ -7,15 +7,15 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late OneDungeonAudioPlayer audioPlayer; setUpAll(() async { audioPlayer = TestAudioPlayer(); - di.injector.registerSingleton(audioPlayer); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/game/view/widgets/menu_button_test.dart b/test/game/view/widgets/menu_button_test.dart index 525f7af..5a31ebd 100644 --- a/test/game/view/widgets/menu_button_test.dart +++ b/test/game/view/widgets/menu_button_test.dart @@ -8,12 +8,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/game/view/widgets/menu_overlay_test.dart b/test/game/view/widgets/menu_overlay_test.dart index 9e042f7..cb97a18 100644 --- a/test/game/view/widgets/menu_overlay_test.dart +++ b/test/game/view/widgets/menu_overlay_test.dart @@ -6,12 +6,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/helpers/helpers.dart b/test/helpers/helpers.dart index 6b4bca9..0078580 100644 --- a/test/helpers/helpers.dart +++ b/test/helpers/helpers.dart @@ -1,3 +1,4 @@ export 'pump_app.dart'; export 'test_audio_player.dart'; export 'test_game.dart'; +export 'test_widgets_binding.dart'; diff --git a/test/helpers/test_widgets_binding.dart b/test/helpers/test_widgets_binding.dart new file mode 100644 index 0000000..6bc3688 --- /dev/null +++ b/test/helpers/test_widgets_binding.dart @@ -0,0 +1,13 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; + +abstract class TestWidgetsBinding { + static void ensureInitialized() { + TestWidgetsFlutterBinding.ensureInitialized(); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('xyz.luan/audioplayers'), + (_) => null, + ); + } +} diff --git a/test/how_to_play/widgets/how_to_dialog_test.dart b/test/how_to_play/widgets/how_to_dialog_test.dart index 60462f9..9610fd9 100644 --- a/test/how_to_play/widgets/how_to_dialog_test.dart +++ b/test/how_to_play/widgets/how_to_dialog_test.dart @@ -7,12 +7,12 @@ import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUpAll(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDownAll(() async { diff --git a/test/one_dungeon_audio/one_dungeon_audio_player_test.dart b/test/one_dungeon_audio/one_dungeon_audio_player_test.dart index 59102a6..487a01a 100644 --- a/test/one_dungeon_audio/one_dungeon_audio_player_test.dart +++ b/test/one_dungeon_audio/one_dungeon_audio_player_test.dart @@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart'; +import '../helpers/helpers.dart'; + class _AudioPlayerTester { void playBackgroundAudio() {} void stopBackgroundAudio() {} @@ -14,7 +16,7 @@ class _AudioPlayerTester { class _MockAudioPlayerTester extends Mock implements _AudioPlayerTester {} void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late _AudioPlayerTester mockAudioPlayerTester; late OneDungeonAudioPlayer audioPlayer; @@ -34,6 +36,10 @@ void main() { }); group('OneDungeonAudioPlayer', () { + test('can be instantiated', () { + expect(OneDungeonAudioPlayer(), isNotNull); + }); + group('sfx', () { test('descending plays as expected', () async { audioPlayer.isFirstRun = false; diff --git a/test/sound/widgets/sound_settings_dialog_test.dart b/test/sound/widgets/sound_settings_dialog_test.dart index df51c26..3ee649e 100644 --- a/test/sound/widgets/sound_settings_dialog_test.dart +++ b/test/sound/widgets/sound_settings_dialog_test.dart @@ -8,15 +8,15 @@ import 'package:sharp_toggle_switch/sharp_toggle_switch.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); late OneDungeonAudioPlayer audioPlayer; setUpAll(() async { audioPlayer = TestAudioPlayer(); - di.injector.registerSingleton(audioPlayer); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(audioPlayer); }); tearDownAll(() async { diff --git a/test/start_game/widgets/start_game_listener_test.dart b/test/start_game/widgets/start_game_listener_test.dart index c68eb31..eb18678 100644 --- a/test/start_game/widgets/start_game_listener_test.dart +++ b/test/start_game/widgets/start_game_listener_test.dart @@ -10,12 +10,12 @@ import 'package:one_dungeon/sound/sound.dart'; import '../../helpers/helpers.dart'; void main() { - TestWidgetsFlutterBinding.ensureInitialized(); + TestWidgetsBinding.ensureInitialized(); setUp(() async { - di.injector.registerSingleton(TestAudioPlayer()); - await di.initializeDependencies(); + await di.injector.unregister(); + di.injector.registerSingleton(TestAudioPlayer()); }); tearDown(() async {