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
2f4864ef
Commit
2f4864ef
authored
Dec 09, 2015
by
Eric Seidel
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #825 from eseidelGoogle/locale_test
Add a test to stocks for changing the locale
parents
003ecb67
09894ec5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
4 deletions
+44
-4
pubspec.yaml
examples/stocks/pubspec.yaml
+3
-0
locale_test.dart
examples/stocks/tests/locale_test.dart
+23
-0
binding.dart
packages/flutter/lib/src/rendering/binding.dart
+6
-2
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+6
-0
test.sh
travis/test.sh
+6
-2
No files found.
examples/stocks/pubspec.yaml
View file @
2f4864ef
...
@@ -4,3 +4,6 @@ dependencies:
...
@@ -4,3 +4,6 @@ dependencies:
path
:
../../packages/flutter
path
:
../../packages/flutter
intl
:
'
>=0.12.4+2
<0.13.0'
intl
:
'
>=0.12.4+2
<0.13.0'
dev_dependencies
:
flutter_test
:
path
:
../../packages/flutter_test
examples/stocks/tests/locale_test.dart
0 → 100644
View file @
2f4864ef
import
'package:test/test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:stocks/main.dart'
as
stocks
;
import
'package:stocks/stock_data.dart'
as
stock_data
;
void
main
(
)
{
stock_data
.
StockDataFetcher
.
actuallyFetchData
=
false
;
test
(
"Test changing locale"
,
()
{
testWidgets
((
WidgetTester
tester
)
{
stocks
.
main
();
tester
.
pump
(
const
Duration
(
seconds:
1
));
// Unclear why duration is required.
Element
<
Text
>
tab
=
tester
.
findText
(
'MARKET'
);
expect
(
tab
,
isNotNull
);
tester
.
setLocale
(
"es"
,
"US"
);
tester
.
pump
();
expect
(
tab
.
widget
.
data
,
equals
(
"MERCADO"
));
});
});
}
packages/flutter/lib/src/rendering/binding.dart
View file @
2f4864ef
...
@@ -248,8 +248,12 @@ class FlutterBinding extends HitTestTarget {
...
@@ -248,8 +248,12 @@ class FlutterBinding extends HitTestTarget {
}
}
void
_handleLocaleChanged
()
{
void
_handleLocaleChanged
()
{
dispatchLocaleChanged
(
ui
.
window
.
locale
);
}
void
dispatchLocaleChanged
(
ui
.
Locale
locale
)
{
for
(
BindingObserver
observer
in
_observers
)
for
(
BindingObserver
observer
in
_observers
)
observer
.
didChangeLocale
(
ui
.
window
.
locale
);
observer
.
didChangeLocale
(
locale
);
}
}
void
_handlePersistentFrameCallback
(
Duration
timeStamp
)
{
void
_handlePersistentFrameCallback
(
Duration
timeStamp
)
{
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
2f4864ef
...
@@ -32,6 +32,12 @@ class WidgetTester {
...
@@ -32,6 +32,12 @@ class WidgetTester {
pump
(
duration
);
pump
(
duration
);
}
}
void
setLocale
(
String
languageCode
,
String
countryCode
)
{
ui
.
Locale
locale
=
new
ui
.
Locale
(
languageCode
,
countryCode
);
FlutterBinding
.
instance
.
dispatchLocaleChanged
(
locale
);
async
.
flushMicrotasks
();
}
void
pump
([
Duration
duration
])
{
void
pump
([
Duration
duration
])
{
if
(
duration
!=
null
)
if
(
duration
!=
null
)
async
.
elapse
(
duration
);
async
.
elapse
(
duration
);
...
...
travis/test.sh
View file @
2f4864ef
#!/bin/bash
#!/bin/bash
set
-ex
set
-ex
export
PATH
=
"
$PWD
/bin:
$PATH
"
# analyze all the Dart code in the repo
# analyze all the Dart code in the repo
./bin/
flutter analyze
--flutter-repo
--no-current-directory
--no-current-package
--congratulate
flutter analyze
--flutter-repo
--no-current-directory
--no-current-package
--congratulate
# flutter package tests
# flutter package tests
./bin/
flutter
test
--flutter-repo
flutter
test
--flutter-repo
(
cd
packages/cassowary
;
pub run
test
-j1
)
(
cd
packages/cassowary
;
pub run
test
-j1
)
# (cd packages/flutter_sprites; ) # No tests to run.
# (cd packages/flutter_sprites; ) # No tests to run.
...
@@ -15,6 +17,8 @@ set -ex
...
@@ -15,6 +17,8 @@ set -ex
# (cd packages/playfair; ) # No tests to run.
# (cd packages/playfair; ) # No tests to run.
# (cd packages/updater; ) # No tests to run.
# (cd packages/updater; ) # No tests to run.
(
cd
examples/stocks
;
flutter
test
)
if
[
$TRAVIS_PULL_REQUEST
=
"false"
]
;
then
if
[
$TRAVIS_PULL_REQUEST
=
"false"
]
;
then
if
[
$TRAVIS_BRANCH
=
"master"
]
;
then
if
[
$TRAVIS_BRANCH
=
"master"
]
;
then
(
cd
packages/flutter
;
dartdoc
)
(
cd
packages/flutter
;
dartdoc
)
...
...
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