|
1 | 1 | import * as TKUnit from '../../tk-unit'; |
2 | | -import { PercentLength, unsetValue, Frame } from '@nativescript/core'; |
| 2 | +import { PercentLength, unsetValue, Frame, Page } from '@nativescript/core'; |
3 | 3 | export * from './frame-tests-common'; |
4 | 4 |
|
5 | 5 | export function test_percent_width_and_height_set_to_page_support() { |
@@ -62,3 +62,22 @@ export function test_percent_margin_set_to_page_support() { |
62 | 62 | TKUnit.assertTrue(PercentLength.equals(currentPage.marginRight, 0)); |
63 | 63 | TKUnit.assertTrue(PercentLength.equals(currentPage.marginBottom, 0)); |
64 | 64 | } |
| 65 | + |
| 66 | +export async function test_back_after_activity_recreation() { |
| 67 | + const frame = Frame.topmost(); |
| 68 | + frame.navigate({ create: () => new Page(), clearHistory: true, animated: false }); |
| 69 | + TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty(), 15); |
| 70 | + const previous = frame.currentPage; |
| 71 | + frame.navigate({ create: () => new Page(), animated: false }); |
| 72 | + TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty(), 15); |
| 73 | + const activity = frame.android.activity; |
| 74 | + activity.recreate(); |
| 75 | + const deadline = Date.now() + 15000; |
| 76 | + while (frame.android.activity === activity || !frame.isLoaded || !frame.currentPage.isLoaded) { |
| 77 | + TKUnit.assertTrue(Date.now() < deadline, 'Activity recreated and Frame loaded'); |
| 78 | + await new Promise((resolve) => setTimeout(resolve, 100)); |
| 79 | + } |
| 80 | + frame.goBack(); |
| 81 | + TKUnit.waitUntilReady(() => frame.navigationQueueIsEmpty(), 15); |
| 82 | + TKUnit.assertEqual(frame.currentPage, previous, 'Back resumes after early native attachment'); |
| 83 | +} |
0 commit comments