michael@0: package org.mozilla.gecko.tests; michael@0: michael@0: import android.content.Context; michael@0: import android.content.Intent; michael@0: import android.content.SharedPreferences; michael@0: import android.os.Bundle; michael@0: michael@0: /** michael@0: * Tests session OOM restore behavior. michael@0: * michael@0: * Loads a session and tests that it is restored correctly. michael@0: */ michael@0: public class testSessionOOMRestore extends SessionTest { michael@0: private Session mSession; michael@0: private static final String PREFS_NAME = "GeckoApp"; michael@0: private static final String PREFS_ALLOW_STATE_BUNDLE = "allowStateBundle"; michael@0: michael@0: @Override michael@0: public void setActivityIntent(Intent intent) { michael@0: PageInfo home = new PageInfo("about:home"); michael@0: PageInfo page1 = new PageInfo("page1"); michael@0: PageInfo page2 = new PageInfo("page2"); michael@0: PageInfo page3 = new PageInfo("page3"); michael@0: PageInfo page4 = new PageInfo("page4"); michael@0: PageInfo page5 = new PageInfo("page5"); michael@0: PageInfo page6 = new PageInfo("page6"); michael@0: michael@0: SessionTab tab1 = new SessionTab(0, home, page1, page2); michael@0: SessionTab tab2 = new SessionTab(1, home, page3, page4); michael@0: SessionTab tab3 = new SessionTab(2, home, page5, page6); michael@0: michael@0: mSession = new Session(1, tab1, tab2, tab3); michael@0: michael@0: String sessionString = buildSessionJSON(mSession); michael@0: writeProfileFile("sessionstore.js", sessionString); michael@0: michael@0: // This feature is pref-protected to prevent other apps from injecting michael@0: // a state bundle, so enable it here. michael@0: SharedPreferences prefs = getInstrumentation().getTargetContext() michael@0: .getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); michael@0: prefs.edit().putBoolean(PREFS_ALLOW_STATE_BUNDLE, true).commit(); michael@0: michael@0: Bundle bundle = new Bundle(); michael@0: bundle.putString("privateSession", null); michael@0: intent.putExtra("stateBundle", bundle); michael@0: michael@0: super.setActivityIntent(intent); michael@0: } michael@0: michael@0: public void testSessionOOMRestore() throws Exception { michael@0: blockForGeckoReady(); michael@0: verifySessionTabs(mSession); michael@0: } michael@0: }