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