@@ -6,12 +6,12 @@ part of engine;
66
77const bool _debugLogHistoryActions = false ;
88
9- class TestHistoryEntry {
9+ class _HistoryEntry {
1010 final dynamic state;
1111 final String title;
1212 final String url;
1313
14- const TestHistoryEntry (this .state, this .title, this .url);
14+ const _HistoryEntry (this .state, this .title, this .url);
1515
1616 @override
1717 String toString () {
@@ -25,30 +25,24 @@ class TestHistoryEntry {
2525/// It keeps a list of history entries and event listeners in memory and
2626/// manipulates them in order to achieve the desired functionality.
2727class TestLocationStrategy extends LocationStrategy {
28- /// Creates a instance of [TestLocationStrategy] with an empty string as the
29- /// path.
30- factory TestLocationStrategy () => TestLocationStrategy .fromEntry (TestHistoryEntry (null , null , '' ));
31-
32- /// Creates an instance of [TestLocationStrategy] and populates it with a list
33- /// that has [initialEntry] as the only item.
34- TestLocationStrategy .fromEntry (TestHistoryEntry initialEntry)
28+ /// Passing a [defaultRouteName] will make the app start at that route. The
29+ /// way it does it is by using it as a path on the first history entry.
30+ TestLocationStrategy ([String defaultRouteName = '' ])
3531 : _currentEntryIndex = 0 ,
36- history = < TestHistoryEntry > [initialEntry ];
32+ history = < _HistoryEntry > [ _HistoryEntry ( null , null , defaultRouteName) ];
3733
3834 @override
3935 String get path => ensureLeading (currentEntry.url, '/' );
4036
4137 int _currentEntryIndex;
42- int get currentEntryIndex => _currentEntryIndex;
43-
44- final List <TestHistoryEntry > history;
38+ final List <_HistoryEntry > history;
4539
46- TestHistoryEntry get currentEntry {
40+ _HistoryEntry get currentEntry {
4741 assert (withinAppHistory);
4842 return history[_currentEntryIndex];
4943 }
5044
51- set currentEntry (TestHistoryEntry entry) {
45+ set currentEntry (_HistoryEntry entry) {
5246 assert (withinAppHistory);
5347 history[_currentEntryIndex] = entry;
5448 }
@@ -68,7 +62,7 @@ class TestLocationStrategy extends LocationStrategy {
6862 // If the user goes A -> B -> C -> D, then goes back to B and pushes a new
6963 // entry called E, we should end up with: A -> B -> E in the history list.
7064 history.removeRange (_currentEntryIndex, history.length);
71- history.add (TestHistoryEntry (state, title, url));
65+ history.add (_HistoryEntry (state, title, url));
7266
7367 if (_debugLogHistoryActions) {
7468 print ('$runtimeType .pushState(...) -> $this ' );
@@ -78,10 +72,7 @@ class TestLocationStrategy extends LocationStrategy {
7872 @override
7973 void replaceState (dynamic state, String title, String url) {
8074 assert (withinAppHistory);
81- if (url == null || url == '' ) {
82- url = currentEntry.url;
83- }
84- currentEntry = TestHistoryEntry (state, title, url);
75+ currentEntry = _HistoryEntry (state, title, url);
8576
8677 if (_debugLogHistoryActions) {
8778 print ('$runtimeType .replaceState(...) -> $this ' );
@@ -158,7 +149,7 @@ class TestLocationStrategy extends LocationStrategy {
158149 String toString () {
159150 final List <String > lines = List <String >(history.length);
160151 for (int i = 0 ; i < history.length; i++ ) {
161- final TestHistoryEntry entry = history[i];
152+ final _HistoryEntry entry = history[i];
162153 lines[i] = _currentEntryIndex == i ? '* $entry ' : ' $entry ' ;
163154 }
164155 return '$runtimeType : [\n ${lines .join ('\n ' )}\n ]' ;
0 commit comments