mobile/android/base/tests/testSessionOOMRestore.java

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:7c4336f628e5
1 package org.mozilla.gecko.tests;
2
3 import android.content.Context;
4 import android.content.Intent;
5 import android.content.SharedPreferences;
6 import android.os.Bundle;
7
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";
17
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");
27
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);
31
32 mSession = new Session(1, tab1, tab2, tab3);
33
34 String sessionString = buildSessionJSON(mSession);
35 writeProfileFile("sessionstore.js", sessionString);
36
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();
42
43 Bundle bundle = new Bundle();
44 bundle.putString("privateSession", null);
45 intent.putExtra("stateBundle", bundle);
46
47 super.setActivityIntent(intent);
48 }
49
50 public void testSessionOOMRestore() throws Exception {
51 blockForGeckoReady();
52 verifySessionTabs(mSession);
53 }
54 }

mercurial