| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.tab; | 5 package org.chromium.chrome.browser.tab; |
| 6 | 6 |
| 7 import android.os.Environment; | 7 import android.os.Environment; |
| 8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| 11 import org.chromium.base.test.util.CommandLineFlags; | |
| 12 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.base.test.util.MetricsUtils.HistogramDelta; | 12 import org.chromium.base.test.util.MetricsUtils.HistogramDelta; |
| 14 import org.chromium.chrome.browser.ChromeActivity; | 13 import org.chromium.chrome.browser.ChromeActivity; |
| 15 import org.chromium.chrome.browser.ChromeSwitches; | |
| 16 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 14 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 17 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; | 15 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; |
| 18 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 19 import org.chromium.content_public.browser.LoadUrlParams; | 17 import org.chromium.content_public.browser.LoadUrlParams; |
| 20 import org.chromium.net.test.EmbeddedTestServer; | 18 import org.chromium.net.test.EmbeddedTestServer; |
| 21 | 19 |
| 22 import java.util.concurrent.Callable; | 20 import java.util.concurrent.Callable; |
| 23 import java.util.concurrent.ExecutionException; | 21 import java.util.concurrent.ExecutionException; |
| 24 | 22 |
| 25 /** | 23 /** |
| (...skipping 26 matching lines...) Expand all Loading... |
| 52 @Override | 50 @Override |
| 53 protected void tearDown() throws Exception { | 51 protected void tearDown() throws Exception { |
| 54 mTestServer.stopAndDestroyServer(); | 52 mTestServer.stopAndDestroyServer(); |
| 55 super.tearDown(); | 53 super.tearDown(); |
| 56 } | 54 } |
| 57 | 55 |
| 58 /** | 56 /** |
| 59 * Verify that Tab.StatusWhenSwitchedBackToForeground is correctly recording
lazy loads. | 57 * Verify that Tab.StatusWhenSwitchedBackToForeground is correctly recording
lazy loads. |
| 60 */ | 58 */ |
| 61 @MediumTest | 59 @MediumTest |
| 62 @CommandLineFlags.Add(ChromeSwitches.DISABLE_DOCUMENT_MODE) | |
| 63 @Feature({"Uma"}) | 60 @Feature({"Uma"}) |
| 64 public void testTabStatusWhenSwitchedToLazyLoads() throws ExecutionException
{ | 61 public void testTabStatusWhenSwitchedToLazyLoads() throws ExecutionException
{ |
| 65 final Tab tab = ThreadUtils.runOnUiThreadBlocking(new Callable<Tab>() { | 62 final Tab tab = ThreadUtils.runOnUiThreadBlocking(new Callable<Tab>() { |
| 66 @Override | 63 @Override |
| 67 public Tab call() { | 64 public Tab call() { |
| 68 Tab bgTab = Tab.createTabForLazyLoad(getActivity(), false, | 65 Tab bgTab = Tab.createTabForLazyLoad(getActivity(), false, |
| 69 getActivity().getWindowAndroid(), TabLaunchType.FROM_LON
GPRESS_BACKGROUND, | 66 getActivity().getWindowAndroid(), TabLaunchType.FROM_LON
GPRESS_BACKGROUND, |
| 70 Tab.INVALID_TAB_ID, new LoadUrlParams(mTestUrl)); | 67 Tab.INVALID_TAB_ID, new LoadUrlParams(mTestUrl)); |
| 71 bgTab.initialize(null, null, new TabDelegateFactory(), true, fal
se); | 68 bgTab.initialize(null, null, new TabDelegateFactory(), true, fal
se); |
| 72 return bgTab; | 69 return bgTab; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 liveBgTab.show(TabSelectionType.FROM_USER); | 171 liveBgTab.show(TabSelectionType.FROM_USER); |
| 175 killedBgTab.show(TabSelectionType.FROM_USER); | 172 killedBgTab.show(TabSelectionType.FROM_USER); |
| 176 frozenBgTab.show(TabSelectionType.FROM_USER); | 173 frozenBgTab.show(TabSelectionType.FROM_USER); |
| 177 } | 174 } |
| 178 }); | 175 }); |
| 179 assertEquals(1, shownLoadCount.getDelta()); | 176 assertEquals(1, shownLoadCount.getDelta()); |
| 180 assertEquals(1, lostLoadCount.getDelta()); | 177 assertEquals(1, lostLoadCount.getDelta()); |
| 181 assertEquals(1, skippedLoadCount.getDelta()); | 178 assertEquals(1, skippedLoadCount.getDelta()); |
| 182 } | 179 } |
| 183 } | 180 } |
| OLD | NEW |