setupTestSweets function

Future<void> setupTestSweets({
  1. bool enabled = TEST_SWEETS_ENABLED,
})

Implementation

Future<void> setupTestSweets({bool enabled = TEST_SWEETS_ENABLED}) async {
  await setupLocator();

  await locator<LocalConfigService>().setEnable(enabled);

  if (!enabled || tsCaptureModeActive) return;

  enableFlutterDriverExtension(
    handler: (message) async {
      ///
      /// take this message and await till the appropriate notification
      /// arrives to the  notification listener of the driver layout
      ///
      if (message == null) return 'message is null $message';

      final testIntegrity = locator<TestIntegrity>();

      testIntegrity.triggeringNotificationType =
          _getNotificationTypeFromCommandMessage(message);

      return await testIntegrity
          .trueIfCommandVerifiedOrFalseIfTimeout(
            TEST_INTEGRITY_TIMEOUT,
          )
          .then<String>(
            (value) => value.toString(),
          );
    },
  );
}