Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
cd34593c
Commit
cd34593c
authored
Jan 10, 2017
by
Adam Barth
Committed by
GitHub
Jan 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test print.dart (#7406)
parent
fb8179bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
3 deletions
+78
-3
print.dart
packages/flutter/lib/src/foundation/print.dart
+3
-3
print_test.dart
packages/flutter/test/foundation/print_test.dart
+75
-0
No files found.
packages/flutter/lib/src/foundation/print.dart
View file @
cd34593c
...
@@ -51,9 +51,9 @@ void debugPrintThrottled(String message, { int wrapWidth }) {
...
@@ -51,9 +51,9 @@ void debugPrintThrottled(String message, { int wrapWidth }) {
}
}
int
_debugPrintedCharacters
=
0
;
int
_debugPrintedCharacters
=
0
;
const
int
_kDebugPrintCapacity
=
16
*
1024
;
const
int
_kDebugPrintCapacity
=
16
*
1024
;
Duration
_kDebugPrintPauseTime
=
const
Duration
(
seconds:
1
);
const
Duration
_kDebugPrintPauseTime
=
const
Duration
(
seconds:
1
);
Queue
<
String
>
_debugPrintBuffer
=
new
Queue
<
String
>();
final
Queue
<
String
>
_debugPrintBuffer
=
new
Queue
<
String
>();
Stopwatch
_debugPrintStopwatch
=
new
Stopwatch
();
final
Stopwatch
_debugPrintStopwatch
=
new
Stopwatch
();
bool
_debugPrintScheduled
=
false
;
bool
_debugPrintScheduled
=
false
;
void
_debugPrintTask
(
)
{
void
_debugPrintTask
(
)
{
_debugPrintScheduled
=
false
;
_debugPrintScheduled
=
false
;
...
...
packages/flutter/test/foundation/print_test.dart
0 → 100644
View file @
cd34593c
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'package:test/test.dart'
;
List
<
String
>
captureOutput
(
VoidCallback
fn
)
{
List
<
String
>
log
=
<
String
>[];
runZoned
(
fn
,
zoneSpecification:
new
ZoneSpecification
(
print:
(
Zone
self
,
ZoneDelegate
parent
,
Zone
zone
,
String
line
)
{
log
.
add
(
line
);
},
));
return
log
;
}
void
main
(
)
{
test
(
'debugPrint'
,
()
{
expect
(
captureOutput
(()
{
debugPrintSynchronously
(
'Hello, world'
);
}),
equals
(<
String
>[
'Hello, world'
])
);
expect
(
captureOutput
(()
{
debugPrintSynchronously
(
'Hello, world'
,
wrapWidth:
10
);
}),
equals
(<
String
>[
'Hello,
\n
world'
])
);
for
(
int
i
=
0
;
i
<
14
;
++
i
)
{
expect
(
captureOutput
(()
{
debugPrintSynchronously
(
'Hello, world'
,
wrapWidth:
i
);
}),
equals
(<
String
>[
'Hello,
\n
world'
])
);
}
expect
(
captureOutput
(()
{
debugPrintThrottled
(
'Hello, world'
);
}),
equals
(<
String
>[
'Hello, world'
])
);
expect
(
captureOutput
(()
{
debugPrintThrottled
(
'Hello, world'
,
wrapWidth:
10
);
}),
equals
(<
String
>[
'Hello,'
,
'world'
])
);
});
test
(
'debugPrint throttling'
,
()
{
new
FakeAsync
().
run
((
FakeAsync
async
)
{
List
<
String
>
log
=
captureOutput
(()
{
debugPrintThrottled
(
'A'
*
(
22
*
1024
)
+
'
\n
B'
);
});
expect
(
log
.
length
,
1
);
async
.
elapse
(
const
Duration
(
seconds:
2
));
expect
(
log
.
length
,
2
);
log
=
captureOutput
(()
{
debugPrintThrottled
(
'C'
*
(
22
*
1024
));
debugPrintThrottled
(
'D'
);
});
expect
(
log
.
length
,
1
);
async
.
elapse
(
const
Duration
(
seconds:
2
));
expect
(
log
.
length
,
2
);
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment