Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | package org.mozilla.gecko.tests; |
michael@0 | 2 | |
michael@0 | 3 | import android.content.Context; |
michael@0 | 4 | import android.content.Intent; |
michael@0 | 5 | import android.content.SharedPreferences; |
michael@0 | 6 | import android.os.Bundle; |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | * Tests session OOM restore behavior. |
michael@0 | 10 | * |
michael@0 | 11 | * Loads a session and tests that it is restored correctly. |
michael@0 | 12 | */ |
michael@0 | 13 | public class testSessionOOMRestore extends SessionTest { |
michael@0 | 14 | private Session mSession; |
michael@0 | 15 | private static final String PREFS_NAME = "GeckoApp"; |
michael@0 | 16 | private static final String PREFS_ALLOW_STATE_BUNDLE = "allowStateBundle"; |
michael@0 | 17 | |
michael@0 | 18 | @Override |
michael@0 | 19 | public void setActivityIntent(Intent intent) { |
michael@0 | 20 | PageInfo home = new PageInfo("about:home"); |
michael@0 | 21 | PageInfo page1 = new PageInfo("page1"); |
michael@0 | 22 | PageInfo page2 = new PageInfo("page2"); |
michael@0 | 23 | PageInfo page3 = new PageInfo("page3"); |
michael@0 | 24 | PageInfo page4 = new PageInfo("page4"); |
michael@0 | 25 | PageInfo page5 = new PageInfo("page5"); |
michael@0 | 26 | PageInfo page6 = new PageInfo("page6"); |
michael@0 | 27 | |
michael@0 | 28 | SessionTab tab1 = new SessionTab(0, home, page1, page2); |
michael@0 | 29 | SessionTab tab2 = new SessionTab(1, home, page3, page4); |
michael@0 | 30 | SessionTab tab3 = new SessionTab(2, home, page5, page6); |
michael@0 | 31 | |
michael@0 | 32 | mSession = new Session(1, tab1, tab2, tab3); |
michael@0 | 33 | |
michael@0 | 34 | String sessionString = buildSessionJSON(mSession); |
michael@0 | 35 | writeProfileFile("sessionstore.js", sessionString); |
michael@0 | 36 | |
michael@0 | 37 | // This feature is pref-protected to prevent other apps from injecting |
michael@0 | 38 | // a state bundle, so enable it here. |
michael@0 | 39 | SharedPreferences prefs = getInstrumentation().getTargetContext() |
michael@0 | 40 | .getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); |
michael@0 | 41 | prefs.edit().putBoolean(PREFS_ALLOW_STATE_BUNDLE, true).commit(); |
michael@0 | 42 | |
michael@0 | 43 | Bundle bundle = new Bundle(); |
michael@0 | 44 | bundle.putString("privateSession", null); |
michael@0 | 45 | intent.putExtra("stateBundle", bundle); |
michael@0 | 46 | |
michael@0 | 47 | super.setActivityIntent(intent); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | public void testSessionOOMRestore() throws Exception { |
michael@0 | 51 | blockForGeckoReady(); |
michael@0 | 52 | verifySessionTabs(mSession); |
michael@0 | 53 | } |
michael@0 | 54 | } |