| 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.notifications; | 5 package org.chromium.chrome.browser.notifications; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Notification; | 8 import android.app.Notification; |
| 9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.graphics.Bitmap; | 12 import android.graphics.Bitmap; |
| 13 import android.graphics.Color; | 13 import android.graphics.Color; |
| 14 import android.graphics.drawable.BitmapDrawable; | 14 import android.graphics.drawable.BitmapDrawable; |
| 15 import android.os.Build; | 15 import android.os.Build; |
| 16 import android.test.InstrumentationTestCase; | |
| 17 import android.test.suitebuilder.annotation.SmallTest; | 16 import android.test.suitebuilder.annotation.SmallTest; |
| 18 import android.util.DisplayMetrics; | 17 import android.util.DisplayMetrics; |
| 19 import android.view.View; | 18 import android.view.View; |
| 20 import android.widget.Button; | 19 import android.widget.Button; |
| 21 import android.widget.ImageView; | 20 import android.widget.ImageView; |
| 22 import android.widget.LinearLayout; | 21 import android.widget.LinearLayout; |
| 23 import android.widget.TextView; | 22 import android.widget.TextView; |
| 24 | 23 |
| 25 import org.chromium.base.test.util.Feature; | 24 import org.chromium.base.test.util.Feature; |
| 26 import org.chromium.chrome.R; | 25 import org.chromium.chrome.R; |
| 26 import org.chromium.content.browser.test.NativeLibraryTestBase; |
| 27 | 27 |
| 28 import java.util.ArrayList; | 28 import java.util.ArrayList; |
| 29 import java.util.Arrays; | 29 import java.util.Arrays; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Instrumentation unit tests for CustomNotificationBuilder. | 32 * Instrumentation unit tests for CustomNotificationBuilder. |
| 33 */ | 33 */ |
| 34 @SuppressLint("NewApi") // For the |extras| property of Notification. | 34 @SuppressLint("NewApi") // For the |extras| property of Notification. |
| 35 @SuppressWarnings("deprecation") // For the |icon| and |largeIcon| properties of
Notification. | 35 @SuppressWarnings("deprecation") // For the |icon| and |largeIcon| properties of
Notification. |
| 36 public class CustomNotificationBuilderTest extends InstrumentationTestCase { | 36 public class CustomNotificationBuilderTest extends NativeLibraryTestBase { |
| 37 |
| 38 @Override |
| 39 public void setUp() throws Exception { |
| 40 super.setUp(); |
| 41 loadNativeLibraryNoBrowserProcess(); |
| 42 } |
| 43 |
| 37 @SmallTest | 44 @SmallTest |
| 38 @Feature({"Browser", "Notifications"}) | 45 @Feature({"Browser", "Notifications"}) |
| 39 public void testSetAll() { | 46 public void testSetAll() { |
| 40 Context context = getInstrumentation().getTargetContext(); | 47 Context context = getInstrumentation().getTargetContext(); |
| 41 | 48 |
| 42 PendingIntent contentIntent = createIntent(context, "Content"); | 49 PendingIntent contentIntent = createIntent(context, "Content"); |
| 43 PendingIntent deleteIntent = createIntent(context, "Delete"); | 50 PendingIntent deleteIntent = createIntent(context, "Delete"); |
| 44 | 51 |
| 45 Bitmap largeIcon = Bitmap.createBitmap( | 52 Bitmap largeIcon = Bitmap.createBitmap( |
| 46 new int[] {Color.RED}, 1 /* width */, 1 /* height */, Bitmap.Con
fig.ARGB_8888); | 53 new int[] {Color.RED}, 1 /* width */, 1 /* height */, Bitmap.Con
fig.ARGB_8888); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 return PendingIntent.getBroadcast( | 273 return PendingIntent.getBroadcast( |
| 267 context, 0 /* requestCode */, intent, PendingIntent.FLAG_UPDATE_
CURRENT); | 274 context, 0 /* requestCode */, intent, PendingIntent.FLAG_UPDATE_
CURRENT); |
| 268 } | 275 } |
| 269 | 276 |
| 270 private static String createString(char character, int length) { | 277 private static String createString(char character, int length) { |
| 271 char[] chars = new char[length]; | 278 char[] chars = new char[length]; |
| 272 Arrays.fill(chars, character); | 279 Arrays.fill(chars, character); |
| 273 return new String(chars); | 280 return new String(chars); |
| 274 } | 281 } |
| 275 } | 282 } |
| OLD | NEW |