OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL; | 7 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL; |
8 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW; | 8 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW; |
9 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE; | 9 import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE; |
10 | 10 |
11 import android.app.Activity; | 11 import android.app.Activity; |
12 import android.app.Application; | 12 import android.app.Application; |
| 13 import android.os.IBinder; |
13 import android.util.Pair; | 14 import android.util.Pair; |
14 | 15 |
15 import org.junit.Assert; | 16 import org.junit.Assert; |
16 import org.junit.Before; | 17 import org.junit.Before; |
17 import org.junit.Test; | 18 import org.junit.Test; |
18 import org.junit.runner.RunWith; | 19 import org.junit.runner.RunWith; |
19 | 20 |
20 import org.robolectric.Robolectric; | 21 import org.robolectric.Robolectric; |
21 import org.robolectric.annotation.Config; | 22 import org.robolectric.annotation.Config; |
22 import org.robolectric.shadows.ShadowLooper; | 23 import org.robolectric.shadows.ShadowLooper; |
23 | 24 |
24 import org.chromium.base.process_launcher.ChildProcessCreationParams; | 25 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
25 import org.chromium.base.process_launcher.FileDescriptorInfo; | 26 import org.chromium.base.process_launcher.FileDescriptorInfo; |
26 import org.chromium.base.test.util.Feature; | 27 import org.chromium.base.test.util.Feature; |
27 import org.chromium.content.common.IChildProcessCallback; | |
28 import org.chromium.content.common.IChildProcessService; | 28 import org.chromium.content.common.IChildProcessService; |
29 import org.chromium.testing.local.LocalRobolectricTestRunner; | 29 import org.chromium.testing.local.LocalRobolectricTestRunner; |
30 | 30 |
31 import java.util.ArrayList; | 31 import java.util.ArrayList; |
32 | 32 |
33 /** | 33 /** |
34 * Unit tests for BindingManagerImpl. The tests run agains mock ChildProcessConn
ection | 34 * Unit tests for BindingManagerImpl. The tests run agains mock ChildProcessConn
ection |
35 * implementation, thus testing only the BindingManagerImpl itself. | 35 * implementation, thus testing only the BindingManagerImpl itself. |
36 * | 36 * |
37 * Default property of being low-end device is overriden, so that both low-end a
nd high-end policies | 37 * Default property of being low-end device is overriden, so that both low-end a
nd high-end policies |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 throw new UnsupportedOperationException(); | 119 throw new UnsupportedOperationException(); |
120 } | 120 } |
121 | 121 |
122 @Override | 122 @Override |
123 public void start(StartCallback startCallback) { | 123 public void start(StartCallback startCallback) { |
124 throw new UnsupportedOperationException(); | 124 throw new UnsupportedOperationException(); |
125 } | 125 } |
126 | 126 |
127 @Override | 127 @Override |
128 public void setupConnection(String[] commandLine, FileDescriptorInfo[] f
ilesToBeMapped, | 128 public void setupConnection(String[] commandLine, FileDescriptorInfo[] f
ilesToBeMapped, |
129 IChildProcessCallback processCallback, ConnectionCallback connec
tionCallbacks) { | 129 IBinder callback, ConnectionCallback connectionCallbacks) { |
130 throw new UnsupportedOperationException(); | 130 throw new UnsupportedOperationException(); |
131 } | 131 } |
132 | 132 |
133 @Override | 133 @Override |
134 public void addModerateBinding() { | 134 public void addModerateBinding() { |
135 mModerateBindingBound = true; | 135 mModerateBindingBound = true; |
136 } | 136 } |
137 | 137 |
138 @Override | 138 @Override |
139 public void removeModerateBinding() { | 139 public void removeModerateBinding() { |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 696 |
697 manager.onSentToBackground(); | 697 manager.onSentToBackground(); |
698 ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); | 698 ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); |
699 Assert.assertFalse(connection.isModerateBindingBound()); | 699 Assert.assertFalse(connection.isModerateBindingBound()); |
700 | 700 |
701 // Bringing Chrome to the foreground should not re-add the moderate bind
ings. | 701 // Bringing Chrome to the foreground should not re-add the moderate bind
ings. |
702 manager.onBroughtToForeground(); | 702 manager.onBroughtToForeground(); |
703 Assert.assertFalse(connection.isModerateBindingBound()); | 703 Assert.assertFalse(connection.isModerateBindingBound()); |
704 } | 704 } |
705 } | 705 } |
OLD | NEW |