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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
| 7 import android.app.Activity; |
7 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
8 | 9 |
9 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
10 import org.chromium.base.test.util.CommandLineFlags; | 11 import org.chromium.base.test.util.CommandLineFlags; |
11 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
12 import org.chromium.chrome.browser.tab.EmptyTabObserver; | 13 import org.chromium.chrome.browser.tab.EmptyTabObserver; |
13 import org.chromium.chrome.browser.tab.Tab; | 14 import org.chromium.chrome.browser.tab.Tab; |
14 import org.chromium.chrome.browser.tab.TabObserver; | 15 import org.chromium.chrome.browser.tab.TabObserver; |
15 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; | 16 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; |
16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 17 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
(...skipping 29 matching lines...) Expand all Loading... |
46 @Override | 47 @Override |
47 protected void setUp() throws Exception { | 48 protected void setUp() throws Exception { |
48 super.setUp(); | 49 super.setUp(); |
49 mTab = getActivity().getActivityTab(); | 50 mTab = getActivity().getActivityTab(); |
50 mTab.addObserver(mTabObserver); | 51 mTab.addObserver(mTabObserver); |
51 mOnTitleUpdatedHelper = new CallbackHelper(); | 52 mOnTitleUpdatedHelper = new CallbackHelper(); |
52 } | 53 } |
53 | 54 |
54 @SmallTest | 55 @SmallTest |
55 @Feature({"Tab"}) | 56 @Feature({"Tab"}) |
| 57 public void testTabContext() throws Throwable { |
| 58 assertFalse("The tab context cannot be an activity", |
| 59 mTab.getContentViewCore().getContext() instanceof Activity); |
| 60 assertNotSame("The tab context's theme should have been updated", |
| 61 mTab.getContentViewCore().getContext().getTheme(), |
| 62 getActivity().getApplication().getTheme()); |
| 63 } |
| 64 |
| 65 @SmallTest |
| 66 @Feature({"Tab"}) |
56 public void testTitleDelayUpdate() throws Throwable { | 67 public void testTitleDelayUpdate() throws Throwable { |
57 final String oldTitle = "oldTitle"; | 68 final String oldTitle = "oldTitle"; |
58 final String newTitle = "newTitle"; | 69 final String newTitle = "newTitle"; |
59 | 70 |
60 loadUrl("data:text/html;charset=utf-8,<html><head><title>" | 71 loadUrl("data:text/html;charset=utf-8,<html><head><title>" |
61 + oldTitle + "</title></head><body/></html>"); | 72 + oldTitle + "</title></head><body/></html>"); |
62 assertEquals("title does not match initial title", oldTitle, mTab.getTit
le()); | 73 assertEquals("title does not match initial title", oldTitle, mTab.getTit
le()); |
63 int currentCallCount = mOnTitleUpdatedHelper.getCallCount(); | 74 int currentCallCount = mOnTitleUpdatedHelper.getCallCount(); |
64 runJavaScriptCodeInCurrentTab("document.title='" + newTitle + "';"); | 75 runJavaScriptCodeInCurrentTab("document.title='" + newTitle + "';"); |
65 mOnTitleUpdatedHelper.waitForCallback(currentCallCount); | 76 mOnTitleUpdatedHelper.waitForCallback(currentCallCount); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 @Feature({"Tab"}) | 134 @Feature({"Tab"}) |
124 public void testTabSecurityLevel() { | 135 public void testTabSecurityLevel() { |
125 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 136 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
126 @Override | 137 @Override |
127 public void run() { | 138 public void run() { |
128 assertEquals(ConnectionSecurityLevel.NONE, mTab.getSecurityLevel
()); | 139 assertEquals(ConnectionSecurityLevel.NONE, mTab.getSecurityLevel
()); |
129 } | 140 } |
130 }); | 141 }); |
131 } | 142 } |
132 } | 143 } |
OLD | NEW |