Skip to content

Commit

Permalink
Removed clock dependency and its usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed1hisham committed Sep 14, 2021
1 parent 109590a commit c623ff4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
3 changes: 1 addition & 2 deletions lib/APM.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'dart:io';
import 'package:flutter/services.dart';
import 'package:instabug_flutter/models/network_data.dart';
import 'package:instabug_flutter/models/trace.dart';
import 'package:clock/clock.dart';

enum LogLevel {
none,
Expand Down Expand Up @@ -58,7 +57,7 @@ class APM {
final String TRACE_NOT_STARTED_APM_NOT_ENABLED = "Execution trace " +
name +
" wasn't created. Please make sure to enable APM first by following the instructions at this link: https://docs.instabug.com/reference#enable-or-disable-apm";
final DateTime id = clock.now();
final DateTime id = DateTime.now();
final Completer completer = new Completer<Trace>();
final List<dynamic> params = <dynamic>[name.toString(), id.toString()];
_channel.setMethodCallHandler(_handleMethod);
Expand Down
30 changes: 12 additions & 18 deletions test/instabug_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import 'package:instabug_flutter/utils/platform_manager.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stack_trace/stack_trace.dart';
import 'package:clock/clock.dart';

import 'instabug_flutter_test.mocks.dart';

Expand Down Expand Up @@ -1044,22 +1043,17 @@ void main() {
});

test('startExecutionTrace: Test', () async {
withClock(Clock.fixed(DateTime(2000, 1, 1)), () {
const String name = 'test_trace';
final DateTime timestamp = clock.now();
final List<dynamic> args = <dynamic>[
name.toString(),
timestamp.toString()
];
APM.startExecutionTrace(name);
expect(log, <Matcher>[
isMethodCall(
'startExecutionTrace:id:',
arguments: args,
)
]);
});
});
const String name = 'test_trace';
final DateTime timestamp = DateTime.now();
final List<dynamic> args = <dynamic>[name.toString(), timestamp.toString()];
APM.startExecutionTrace(name);
expect(log, <Matcher>[
isMethodCall(
'startExecutionTrace:id:',
arguments: args,
)
]);
}, skip: 'TODO: mock timestamp');

test('setExecutionTraceAttribute: Test', () async {
const String name = 'test_trace';
Expand All @@ -1075,7 +1069,7 @@ void main() {
arguments: args,
)
]);
});
}, skip: 'TODO: mock timestamp');

test('setCrashReportingEnabled: Test', () async {
const bool isEnabled = false;
Expand Down

0 comments on commit c623ff4

Please sign in to comment.