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.Bundle; | 13 import android.os.Bundle; |
14 import android.util.Pair; | 14 import android.util.Pair; |
15 | 15 |
| 16 import org.junit.Assert; |
| 17 import org.junit.Before; |
| 18 import org.junit.Test; |
| 19 import org.junit.runner.RunWith; |
| 20 |
| 21 import org.robolectric.Robolectric; |
| 22 import org.robolectric.annotation.Config; |
| 23 import org.robolectric.shadows.ShadowLooper; |
| 24 |
16 import org.chromium.base.test.util.Feature; | 25 import org.chromium.base.test.util.Feature; |
17 import org.chromium.content.common.FileDescriptorInfo; | 26 import org.chromium.content.common.FileDescriptorInfo; |
18 import org.chromium.content.common.IChildProcessCallback; | 27 import org.chromium.content.common.IChildProcessCallback; |
19 import org.chromium.content.common.IChildProcessService; | 28 import org.chromium.content.common.IChildProcessService; |
20 import org.chromium.testing.local.LocalRobolectricTestRunner; | 29 import org.chromium.testing.local.LocalRobolectricTestRunner; |
21 import org.junit.Assert; | |
22 import org.junit.Before; | |
23 import org.junit.Test; | |
24 import org.junit.runner.RunWith; | |
25 import org.robolectric.Robolectric; | |
26 import org.robolectric.annotation.Config; | |
27 import org.robolectric.shadows.ShadowLooper; | |
28 | 30 |
29 import java.util.ArrayList; | 31 import java.util.ArrayList; |
30 | 32 |
31 /** | 33 /** |
32 * Unit tests for BindingManagerImpl. The tests run agains mock ChildProcessConn
ection | 34 * Unit tests for BindingManagerImpl. The tests run agains mock ChildProcessConn
ection |
33 * implementation, thus testing only the BindingManagerImpl itself. | 35 * implementation, thus testing only the BindingManagerImpl itself. |
34 * | 36 * |
35 * 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 |
36 * are tested. | 38 * are tested. |
37 */ | 39 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 public boolean isInSandbox() { | 113 public boolean isInSandbox() { |
112 return true; | 114 return true; |
113 } | 115 } |
114 | 116 |
115 @Override | 117 @Override |
116 public IChildProcessService getService() { | 118 public IChildProcessService getService() { |
117 throw new UnsupportedOperationException(); | 119 throw new UnsupportedOperationException(); |
118 } | 120 } |
119 | 121 |
120 @Override | 122 @Override |
121 public void start(String[] commandLine) { | 123 public void start(String[] commandLine, StartCallback startCallback) { |
122 throw new UnsupportedOperationException(); | 124 throw new UnsupportedOperationException(); |
123 } | 125 } |
124 | 126 |
125 @Override | 127 @Override |
126 public void setupConnection(String[] commandLine, FileDescriptorInfo[] f
ilesToBeMapped, | 128 public void setupConnection(String[] commandLine, FileDescriptorInfo[] f
ilesToBeMapped, |
127 IChildProcessCallback processCallback, ConnectionCallback connec
tionCallbacks, | 129 IChildProcessCallback processCallback, ConnectionCallback connec
tionCallbacks, |
128 Bundle sharedRelros) { | 130 Bundle sharedRelros) { |
129 throw new UnsupportedOperationException(); | 131 throw new UnsupportedOperationException(); |
130 } | 132 } |
131 | 133 |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 715 |
714 manager.onSentToBackground(); | 716 manager.onSentToBackground(); |
715 ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); | 717 ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); |
716 Assert.assertFalse(connection.isModerateBindingBound()); | 718 Assert.assertFalse(connection.isModerateBindingBound()); |
717 | 719 |
718 // Bringing Chrome to the foreground should not re-add the moderate bind
ings. | 720 // Bringing Chrome to the foreground should not re-add the moderate bind
ings. |
719 manager.onBroughtToForeground(); | 721 manager.onBroughtToForeground(); |
720 Assert.assertFalse(connection.isModerateBindingBound()); | 722 Assert.assertFalse(connection.isModerateBindingBound()); |
721 } | 723 } |
722 } | 724 } |
OLD | NEW |