-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a2bbfa
Showing
11 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This is a generated file; do not edit or check into version control. | ||
firebase_core=C:\\Users\\ciriousjoker\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dartlang.org\\firebase_core-1.11.0\\ | ||
firebase_core_web=C:\\Users\\ciriousjoker\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dartlang.org\\firebase_core_web-1.5.3\\ | ||
firebase_performance=C:\\Users\\ciriousjoker\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dartlang.org\\firebase_performance-0.8.0\\ | ||
firebase_performance_web=C:\\Users\\ciriousjoker\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dartlang.org\\firebase_performance_web-0.1.0+4\\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"firebase_core","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-1.11.0\\\\","dependencies":[]},{"name":"firebase_performance","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_performance-0.8.0\\\\","dependencies":["firebase_core"]}],"android":[{"name":"firebase_core","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-1.11.0\\\\","dependencies":[]},{"name":"firebase_performance","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_performance-0.8.0\\\\","dependencies":["firebase_core"]}],"macos":[{"name":"firebase_core","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-1.11.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"firebase_core_web","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-1.5.3\\\\","dependencies":[]},{"name":"firebase_performance_web","path":"C:\\\\Users\\\\ciriousjoker\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_performance_web-0.1.0+4\\\\","dependencies":["firebase_core_web"]}]},"dependencyGraph":[{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_performance","dependencies":["firebase_core","firebase_performance_web"]},{"name":"firebase_performance_web","dependencies":["firebase_core","firebase_core_web"]}],"date_created":"2022-01-08 09:36:15.643430","version":"2.8.1"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
BSD 2-Clause License | ||
|
||
Copyright (c) 2022, Philipp Bauer All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Fake Firebase Performance | ||
|
||
[![pub package](https://img.shields.io/pub/v/fake_firebase_performance.svg)](https://pub.dartlang.org/packages/fake_firebase_performance) | ||
|
||
Fakes to write unit tests for apps using Firebase Performance monitoring. Instantiate a `FakeFirebasePerformance`, then pass it around your project to replace `FirebasePerformance.instance`. This fake acts like `FirebasePerformance` except it will load mocked data instead. | ||
|
||
## Usage | ||
|
||
### A simple usage example | ||
|
||
```dart | ||
import 'package:fake_firebase_performance/fake_firebase_performance.dart'; | ||
void main() async { | ||
final perf = FakeFirebasePerformance(); | ||
perf.isPerformanceCollectionEnabled(); // will return false | ||
perf.newTrace('test'); // will do nothing | ||
perf.newHttpMetric("https://example.com/", HttpMethod.Get); // will do nothing | ||
} | ||
``` | ||
|
||
This `perf` object needs to replace the real `FirebasePerformance.instance` during testing. You can do this for example with [Riverpod](https://pub.dev/packages/riverpod) or by doing something like this: | ||
|
||
```dart | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
title: 'FirebasePerformance Example', | ||
home: MyApp(overrideFirebasePerformance: perf), | ||
), | ||
); | ||
``` | ||
|
||
## Missing functionality | ||
|
||
- `perf.app` will throw | ||
- `perf.pluginConstants` is empty | ||
- `perf.newTrace()` does nothing | ||
- `perf.newHttpMetric()` does nothing | ||
|
||
## Compatibility table | ||
|
||
| firebase_performance | fake_firebase_performance | | ||
| -------------------- | ------------------------- | | ||
| >=0.8.0 | 1.0.0 | | ||
|
||
## Features and bugs | ||
|
||
Please file feature requests and bugs at the [issue tracker](https://github.com/CiriousJoker/fake_firebase_performance/issues). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:lint/analysis_options.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library fake_firebase_performance; | ||
|
||
export 'src/fake_firebase_performance_instance.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
library fake_firebase_performance; | ||
|
||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:firebase_performance/firebase_performance.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
|
||
/// Fake implementation of [FirebasePerformance] for testing. | ||
class FakeFirebasePerformance | ||
with ChangeNotifier | ||
implements FirebasePerformance { | ||
@override | ||
late FirebaseApp app; | ||
|
||
@override | ||
Future<bool> isPerformanceCollectionEnabled() { | ||
return Future.value(false); | ||
} | ||
|
||
@override | ||
HttpMetric newHttpMetric(String url, HttpMethod httpMethod) { | ||
return FakeHttpMetric(); | ||
} | ||
|
||
@override | ||
Trace newTrace(String name) { | ||
return FakeTrace(); | ||
} | ||
|
||
@override | ||
Map get pluginConstants => {}; | ||
|
||
@override | ||
Future<void> setPerformanceCollectionEnabled(bool enabled) { | ||
return Future.value(); | ||
} | ||
} | ||
|
||
class FakeHttpMetric implements HttpMetric { | ||
@override | ||
int? httpResponseCode; | ||
|
||
@override | ||
int? requestPayloadSize; | ||
|
||
@override | ||
String? responseContentType; | ||
|
||
@override | ||
int? responsePayloadSize; | ||
|
||
@override | ||
String? getAttribute(String name) => null; | ||
|
||
@override | ||
Map<String, String> getAttributes() => {}; | ||
|
||
@override | ||
void putAttribute(String name, String value) { | ||
// noop | ||
} | ||
|
||
@override | ||
void removeAttribute(String name) { | ||
// noop | ||
} | ||
|
||
@override | ||
Future<void> start() { | ||
return Future.value(); | ||
} | ||
|
||
@override | ||
Future<void> stop() { | ||
return Future.value(); | ||
} | ||
} | ||
|
||
class FakeTrace implements Trace { | ||
@override | ||
String? getAttribute(String name) => null; | ||
|
||
@override | ||
Map<String, String> getAttributes() => {}; | ||
|
||
@override | ||
int getMetric(String name) => 0; | ||
|
||
@override | ||
void incrementMetric(String name, int value) { | ||
// noop | ||
} | ||
|
||
@override | ||
void putAttribute(String name, String value) { | ||
// noop | ||
} | ||
|
||
@override | ||
void removeAttribute(String name) { | ||
// noop | ||
} | ||
|
||
@override | ||
void setMetric(String name, int value) { | ||
// noop | ||
} | ||
|
||
@override | ||
Future<void> start() { | ||
return Future.value(); | ||
} | ||
|
||
@override | ||
Future<void> stop() { | ||
return Future.value(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: fake_firebase_performance | ||
description: Fake Firebase Performance for use during Flutter unit & widget tests. | ||
version: 1.0.0 | ||
homepage: https://philippbauer.me/ | ||
repository: https://github.com/CiriousJoker/fake_firebase_performance | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
flutter: ">=1.17.0" | ||
|
||
dependencies: | ||
firebase_core: any | ||
firebase_performance: ">=0.8.0 <1.0.0" | ||
flutter: | ||
sdk: flutter | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
lint: ^1.8.1 | ||
|
||
flutter: |