コード例 #1
0
  /**
   * Tests that each model loads the subset of tabs it is responsible for. In this case, just check
   * that the model has the expected number of tabs to load. Since each model is loading a different
   * number of tabs we can tell if they are each attempting to load their specific set.
   *
   * @throws IOException
   */
  @SmallTest
  public void testOnlyLoadsSingleModel() throws IOException {
    TabModelSelector selector0 = new MockTabModelSelector(3, 3, null);
    TabModelSelector selector1 = new MockTabModelSelector(2, 1, null);

    writeStateFile(selector0, 0);
    writeStateFile(selector1, 1);

    TabModelSelector selectorIn0 = new MockTabModelSelector(0, 0, null);
    TabModelSelector selectorIn1 = new MockTabModelSelector(0, 0, null);

    TabPersistentStore storeIn0 =
        new TabPersistentStore(selectorIn0, 0, getInstrumentation().getTargetContext(), null, null);
    TabPersistentStore storeIn1 =
        new TabPersistentStore(selectorIn1, 1, getInstrumentation().getTargetContext(), null, null);

    disableReporting();
    storeIn0.loadStateInternal();
    storeIn1.loadStateInternal();

    assertEquals("Unexpected number of tabs to load", 6, storeIn0.getRestoredTabCount());
    assertEquals("Unexpected number of tabst o load", 3, storeIn1.getRestoredTabCount());
  }
コード例 #2
0
  /**
   * Tests that the max id returned is the max of all of the tab models.
   *
   * @throws IOException
   */
  @SmallTest
  public void testFindsMaxIdProperly() throws IOException {
    TabModelSelector selector0 = new MockTabModelSelector(1, 1, null);
    TabModelSelector selector1 = new MockTabModelSelector(1, 1, null);

    writeStateFile(selector0, 0);
    writeStateFile(selector1, 1);

    TabModelSelector selectorIn = new MockTabModelSelector(0, 0, null);
    TabPersistentStore storeIn =
        new TabPersistentStore(selectorIn, 0, getInstrumentation().getTargetContext(), null, null);

    int maxId = Math.max(getMaxId(selector0), getMaxId(selector1));
    disableReporting();
    assertEquals("Invalid next id", maxId + 1, storeIn.loadStateInternal());
  }