Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuUiTest.java

Issue 2942963002: corrected wrong options showing on context menus. (Closed)
Patch Set: empty Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.contextmenu; 5 package org.chromium.chrome.browser.contextmenu;
6 6
7 import android.support.design.widget.TabLayout; 7 import android.support.design.widget.TabLayout;
8 import android.support.test.filters.SmallTest; 8 import android.support.test.filters.SmallTest;
9 import android.util.Pair; 9 import android.util.Pair;
10 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 public void testURLIsShownOnContextMenu() throws ExecutionException { 139 public void testURLIsShownOnContextMenu() throws ExecutionException {
140 final TabularContextMenuUi dialog = new TabularContextMenuUi(null); 140 final TabularContextMenuUi dialog = new TabularContextMenuUi(null);
141 final List<? extends ContextMenuItem> item = 141 final List<? extends ContextMenuItem> item =
142 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S, 142 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S,
143 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS); 143 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS);
144 final String expectedUrl = "http://google.com"; 144 final String expectedUrl = "http://google.com";
145 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() { 145 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() {
146 @Override 146 @Override
147 public View call() { 147 public View call() {
148 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(), 148 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(),
149 new MockMenuParams(expectedUrl), Collections.unmodifiabl eList(item), false, 149 new MockMenuParams(expectedUrl), Collections.unmodifiabl eList(item), false);
150 item.size());
151 } 150 }
152 }); 151 });
153 152
154 TextView textView = (TextView) view.findViewById(R.id.context_header_tex t); 153 TextView textView = (TextView) view.findViewById(R.id.context_header_tex t);
155 Assert.assertEquals(expectedUrl, String.valueOf(textView.getText())); 154 Assert.assertEquals(expectedUrl, String.valueOf(textView.getText()));
156 } 155 }
157 156
158 @Test 157 @Test
159 @SmallTest 158 @SmallTest
160 @Feature({"CustomContextMenu"}) 159 @Feature({"CustomContextMenu"})
161 public void testHeaderIsNotShownWhenThereIsNoParams() throws ExecutionExcept ion { 160 public void testHeaderIsNotShownWhenThereIsNoParams() throws ExecutionExcept ion {
162 final TabularContextMenuUi dialog = new TabularContextMenuUi(null); 161 final TabularContextMenuUi dialog = new TabularContextMenuUi(null);
163 final List<? extends ContextMenuItem> item = 162 final List<? extends ContextMenuItem> item =
164 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S, 163 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S,
165 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS); 164 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS);
166 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() { 165 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() {
167 @Override 166 @Override
168 public View call() { 167 public View call() {
169 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(), 168 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(),
170 new MockMenuParams(""), Collections.unmodifiableList(ite m), false, 169 new MockMenuParams(""), Collections.unmodifiableList(ite m), false);
171 item.size());
172 } 170 }
173 }); 171 });
174 172
175 Assert.assertEquals(view.findViewById(R.id.context_header_text).getVisib ility(), View.GONE); 173 Assert.assertEquals(view.findViewById(R.id.context_header_text).getVisib ility(), View.GONE);
176 Assert.assertEquals(view.findViewById(R.id.context_divider).getVisibilit y(), View.GONE); 174 Assert.assertEquals(view.findViewById(R.id.context_divider).getVisibilit y(), View.GONE);
177 } 175 }
178 176
179 @Test 177 @Test
180 @SmallTest 178 @SmallTest
181 @Feature({"CustomContextMenu"}) 179 @Feature({"CustomContextMenu"})
182 public void testLinkShowsMultipleLinesWhenClicked() throws ExecutionExceptio n { 180 public void testLinkShowsMultipleLinesWhenClicked() throws ExecutionExceptio n {
183 final TabularContextMenuUi dialog = new TabularContextMenuUi(null); 181 final TabularContextMenuUi dialog = new TabularContextMenuUi(null);
184 final List<? extends ContextMenuItem> item = 182 final List<? extends ContextMenuItem> item =
185 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S, 183 CollectionUtil.newArrayList(ChromeContextMenuItem.ADD_TO_CONTACT S,
186 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS); 184 ChromeContextMenuItem.CALL, ChromeContextMenuItem.COPY_L INK_ADDRESS);
187 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() { 185 View view = ThreadUtils.runOnUiThreadBlocking(new Callable<View>() {
188 @Override 186 @Override
189 public View call() { 187 public View call() {
190 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(), 188 return dialog.createContextMenuPageUi(mActivityTestRule.getActiv ity(),
191 new MockMenuParams("http://google.com"), Collections.unm odifiableList(item), 189 new MockMenuParams("http://google.com"), Collections.unm odifiableList(item),
192 false, item.size()); 190 false);
193 } 191 }
194 }); 192 });
195 193
196 final TextView headerTextView = (TextView) view.findViewById(R.id.contex t_header_text); 194 final TextView headerTextView = (TextView) view.findViewById(R.id.contex t_header_text);
197 int expectedMaxLines = 1; 195 int expectedMaxLines = 1;
198 int actualMaxLines = headerTextView.getMaxLines(); 196 int actualMaxLines = headerTextView.getMaxLines();
199 Assert.assertEquals("Expected a different number of default maximum line s.", 197 Assert.assertEquals("Expected a different number of default maximum line s.",
200 expectedMaxLines, actualMaxLines); 198 expectedMaxLines, actualMaxLines);
201 199
202 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 200 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
203 @Override 201 @Override
204 public void run() { 202 public void run() {
205 headerTextView.callOnClick(); 203 headerTextView.callOnClick();
206 } 204 }
207 }); 205 });
208 206
209 expectedMaxLines = Integer.MAX_VALUE; 207 expectedMaxLines = Integer.MAX_VALUE;
210 actualMaxLines = headerTextView.getMaxLines(); 208 actualMaxLines = headerTextView.getMaxLines();
211 Assert.assertEquals( 209 Assert.assertEquals(
212 "Expected a different number of maximum lines when the header is clicked.", 210 "Expected a different number of maximum lines when the header is clicked.",
213 expectedMaxLines, actualMaxLines); 211 expectedMaxLines, actualMaxLines);
214 } 212 }
215 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698