Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 package org.mozilla.gecko.tests;
3 import android.content.Context;
4 import android.content.Intent;
5 import android.content.SharedPreferences;
6 import android.os.Bundle;
8 /**
9 * Tests session OOM restore behavior.
10 *
11 * Loads a session and tests that it is restored correctly.
12 */
13 public class testSessionOOMRestore extends SessionTest {
14 private Session mSession;
15 private static final String PREFS_NAME = "GeckoApp";
16 private static final String PREFS_ALLOW_STATE_BUNDLE = "allowStateBundle";
18 @Override
19 public void setActivityIntent(Intent intent) {
20 PageInfo home = new PageInfo("about:home");
21 PageInfo page1 = new PageInfo("page1");
22 PageInfo page2 = new PageInfo("page2");
23 PageInfo page3 = new PageInfo("page3");
24 PageInfo page4 = new PageInfo("page4");
25 PageInfo page5 = new PageInfo("page5");
26 PageInfo page6 = new PageInfo("page6");
28 SessionTab tab1 = new SessionTab(0, home, page1, page2);
29 SessionTab tab2 = new SessionTab(1, home, page3, page4);
30 SessionTab tab3 = new SessionTab(2, home, page5, page6);
32 mSession = new Session(1, tab1, tab2, tab3);
34 String sessionString = buildSessionJSON(mSession);
35 writeProfileFile("sessionstore.js", sessionString);
37 // This feature is pref-protected to prevent other apps from injecting
38 // a state bundle, so enable it here.
39 SharedPreferences prefs = getInstrumentation().getTargetContext()
40 .getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
41 prefs.edit().putBoolean(PREFS_ALLOW_STATE_BUNDLE, true).commit();
43 Bundle bundle = new Bundle();
44 bundle.putString("privateSession", null);
45 intent.putExtra("stateBundle", bundle);
47 super.setActivityIntent(intent);
48 }
50 public void testSessionOOMRestore() throws Exception {
51 blockForGeckoReady();
52 verifySessionTabs(mSession);
53 }
54 }