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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura_browsertest.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EXPECT_FALSE(controller.CanGoForward()); 189 EXPECT_FALSE(controller.CanGoForward());
190 190
191 aura::Window* content = web_contents->GetView()->GetContentNativeView(); 191 aura::Window* content = web_contents->GetView()->GetContentNativeView();
192 gfx::Rect bounds = content->GetBoundsInRootWindow(); 192 gfx::Rect bounds = content->GetBoundsInRootWindow();
193 aura::test::EventGenerator generator(content->GetRootWindow(), content); 193 aura::test::EventGenerator generator(content->GetRootWindow(), content);
194 const int kScrollDurationMs = 20; 194 const int kScrollDurationMs = 20;
195 const int kScrollSteps = 10; 195 const int kScrollSteps = 10;
196 196
197 { 197 {
198 // Do a swipe-right now. That should navigate backwards. 198 // Do a swipe-right now. That should navigate backwards.
199 string16 expected_title = ASCIIToUTF16("Title: #1"); 199 base::string16 expected_title = ASCIIToUTF16("Title: #1");
200 content::TitleWatcher title_watcher(web_contents, expected_title); 200 content::TitleWatcher title_watcher(web_contents, expected_title);
201 generator.GestureScrollSequence( 201 generator.GestureScrollSequence(
202 gfx::Point(bounds.x() + 2, bounds.y() + 10), 202 gfx::Point(bounds.x() + 2, bounds.y() + 10),
203 gfx::Point(bounds.right() - 10, bounds.y() + 10), 203 gfx::Point(bounds.right() - 10, bounds.y() + 10),
204 base::TimeDelta::FromMilliseconds(kScrollDurationMs), 204 base::TimeDelta::FromMilliseconds(kScrollDurationMs),
205 kScrollSteps); 205 kScrollSteps);
206 string16 actual_title = title_watcher.WaitAndGetTitle(); 206 base::string16 actual_title = title_watcher.WaitAndGetTitle();
207 EXPECT_EQ(expected_title, actual_title); 207 EXPECT_EQ(expected_title, actual_title);
208 value = content::ExecuteScriptAndGetValue(view_host, "get_current()"); 208 value = content::ExecuteScriptAndGetValue(view_host, "get_current()");
209 ASSERT_TRUE(value->GetAsInteger(&index)); 209 ASSERT_TRUE(value->GetAsInteger(&index));
210 EXPECT_EQ(1, index); 210 EXPECT_EQ(1, index);
211 EXPECT_TRUE(controller.CanGoBack()); 211 EXPECT_TRUE(controller.CanGoBack());
212 EXPECT_TRUE(controller.CanGoForward()); 212 EXPECT_TRUE(controller.CanGoForward());
213 } 213 }
214 214
215 { 215 {
216 // Do a fling-right now. That should navigate backwards. 216 // Do a fling-right now. That should navigate backwards.
217 string16 expected_title = ASCIIToUTF16("Title:"); 217 base::string16 expected_title = ASCIIToUTF16("Title:");
218 content::TitleWatcher title_watcher(web_contents, expected_title); 218 content::TitleWatcher title_watcher(web_contents, expected_title);
219 generator.GestureScrollSequence( 219 generator.GestureScrollSequence(
220 gfx::Point(bounds.x() + 2, bounds.y() + 10), 220 gfx::Point(bounds.x() + 2, bounds.y() + 10),
221 gfx::Point(bounds.right() - 10, bounds.y() + 10), 221 gfx::Point(bounds.right() - 10, bounds.y() + 10),
222 base::TimeDelta::FromMilliseconds(kScrollDurationMs), 222 base::TimeDelta::FromMilliseconds(kScrollDurationMs),
223 kScrollSteps); 223 kScrollSteps);
224 string16 actual_title = title_watcher.WaitAndGetTitle(); 224 base::string16 actual_title = title_watcher.WaitAndGetTitle();
225 EXPECT_EQ(expected_title, actual_title); 225 EXPECT_EQ(expected_title, actual_title);
226 value = content::ExecuteScriptAndGetValue(view_host, "get_current()"); 226 value = content::ExecuteScriptAndGetValue(view_host, "get_current()");
227 ASSERT_TRUE(value->GetAsInteger(&index)); 227 ASSERT_TRUE(value->GetAsInteger(&index));
228 EXPECT_EQ(0, index); 228 EXPECT_EQ(0, index);
229 EXPECT_FALSE(controller.CanGoBack()); 229 EXPECT_FALSE(controller.CanGoBack());
230 EXPECT_TRUE(controller.CanGoForward()); 230 EXPECT_TRUE(controller.CanGoForward());
231 } 231 }
232 232
233 { 233 {
234 // Do a swipe-left now. That should navigate forward. 234 // Do a swipe-left now. That should navigate forward.
235 string16 expected_title = ASCIIToUTF16("Title: #1"); 235 base::string16 expected_title = ASCIIToUTF16("Title: #1");
236 content::TitleWatcher title_watcher(web_contents, expected_title); 236 content::TitleWatcher title_watcher(web_contents, expected_title);
237 generator.GestureScrollSequence( 237 generator.GestureScrollSequence(
238 gfx::Point(bounds.right() - 10, bounds.y() + 10), 238 gfx::Point(bounds.right() - 10, bounds.y() + 10),
239 gfx::Point(bounds.x() + 2, bounds.y() + 10), 239 gfx::Point(bounds.x() + 2, bounds.y() + 10),
240 base::TimeDelta::FromMilliseconds(kScrollDurationMs), 240 base::TimeDelta::FromMilliseconds(kScrollDurationMs),
241 kScrollSteps); 241 kScrollSteps);
242 string16 actual_title = title_watcher.WaitAndGetTitle(); 242 base::string16 actual_title = title_watcher.WaitAndGetTitle();
243 EXPECT_EQ(expected_title, actual_title); 243 EXPECT_EQ(expected_title, actual_title);
244 value = content::ExecuteScriptAndGetValue(view_host, "get_current()"); 244 value = content::ExecuteScriptAndGetValue(view_host, "get_current()");
245 ASSERT_TRUE(value->GetAsInteger(&index)); 245 ASSERT_TRUE(value->GetAsInteger(&index));
246 EXPECT_EQ(1, index); 246 EXPECT_EQ(1, index);
247 EXPECT_TRUE(controller.CanGoBack()); 247 EXPECT_TRUE(controller.CanGoBack());
248 EXPECT_TRUE(controller.CanGoForward()); 248 EXPECT_TRUE(controller.CanGoForward());
249 } 249 }
250 } 250 }
251 251
252 int GetCurrentIndex() { 252 int GetCurrentIndex() {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 web_contents->GetController().GetEntryAtIndex(2)); 431 web_contents->GetController().GetEntryAtIndex(2));
432 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); 432 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry));
433 433
434 entry = NavigationEntryImpl::FromNavigationEntry( 434 entry = NavigationEntryImpl::FromNavigationEntry(
435 web_contents->GetController().GetEntryAtIndex(3)); 435 web_contents->GetController().GetEntryAtIndex(3));
436 EXPECT_FALSE(entry->screenshot().get()); 436 EXPECT_FALSE(entry->screenshot().get());
437 437
438 { 438 {
439 // Now, swipe right to navigate backwards. This should navigate away from 439 // Now, swipe right to navigate backwards. This should navigate away from
440 // index 3 to index 2, and index 3 should have a screenshot. 440 // index 3 to index 2, and index 3 should have a screenshot.
441 string16 expected_title = ASCIIToUTF16("Title: #2"); 441 base::string16 expected_title = ASCIIToUTF16("Title: #2");
442 content::TitleWatcher title_watcher(web_contents, expected_title); 442 content::TitleWatcher title_watcher(web_contents, expected_title);
443 aura::Window* content = web_contents->GetView()->GetContentNativeView(); 443 aura::Window* content = web_contents->GetView()->GetContentNativeView();
444 gfx::Rect bounds = content->GetBoundsInRootWindow(); 444 gfx::Rect bounds = content->GetBoundsInRootWindow();
445 aura::test::EventGenerator generator(content->GetRootWindow(), content); 445 aura::test::EventGenerator generator(content->GetRootWindow(), content);
446 generator.GestureScrollSequence( 446 generator.GestureScrollSequence(
447 gfx::Point(bounds.x() + 2, bounds.y() + 10), 447 gfx::Point(bounds.x() + 2, bounds.y() + 10),
448 gfx::Point(bounds.right() - 10, bounds.y() + 10), 448 gfx::Point(bounds.right() - 10, bounds.y() + 10),
449 base::TimeDelta::FromMilliseconds(20), 449 base::TimeDelta::FromMilliseconds(20),
450 1); 450 1);
451 string16 actual_title = title_watcher.WaitAndGetTitle(); 451 base::string16 actual_title = title_watcher.WaitAndGetTitle();
452 EXPECT_EQ(expected_title, actual_title); 452 EXPECT_EQ(expected_title, actual_title);
453 EXPECT_EQ(2, GetCurrentIndex()); 453 EXPECT_EQ(2, GetCurrentIndex());
454 screenshot_manager()->WaitUntilScreenshotIsReady(); 454 screenshot_manager()->WaitUntilScreenshotIsReady();
455 entry = NavigationEntryImpl::FromNavigationEntry( 455 entry = NavigationEntryImpl::FromNavigationEntry(
456 web_contents->GetController().GetEntryAtIndex(3)); 456 web_contents->GetController().GetEntryAtIndex(3));
457 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); 457 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry));
458 } 458 }
459 459
460 // Navigate a couple more times. 460 // Navigate a couple more times.
461 ExecuteSyncJSFunction(view_host, "navigate_next()"); 461 ExecuteSyncJSFunction(view_host, "navigate_next()");
462 EXPECT_EQ(3, GetCurrentIndex()); 462 EXPECT_EQ(3, GetCurrentIndex());
463 ExecuteSyncJSFunction(view_host, "navigate_next()"); 463 ExecuteSyncJSFunction(view_host, "navigate_next()");
464 EXPECT_EQ(4, GetCurrentIndex()); 464 EXPECT_EQ(4, GetCurrentIndex());
465 screenshot_manager()->WaitUntilScreenshotIsReady(); 465 screenshot_manager()->WaitUntilScreenshotIsReady();
466 entry = NavigationEntryImpl::FromNavigationEntry( 466 entry = NavigationEntryImpl::FromNavigationEntry(
467 web_contents->GetController().GetEntryAtIndex(4)); 467 web_contents->GetController().GetEntryAtIndex(4));
468 EXPECT_FALSE(entry->screenshot().get()); 468 EXPECT_FALSE(entry->screenshot().get());
469 469
470 { 470 {
471 // Navigate back in history. 471 // Navigate back in history.
472 string16 expected_title = ASCIIToUTF16("Title: #3"); 472 base::string16 expected_title = ASCIIToUTF16("Title: #3");
473 content::TitleWatcher title_watcher(web_contents, expected_title); 473 content::TitleWatcher title_watcher(web_contents, expected_title);
474 web_contents->GetController().GoBack(); 474 web_contents->GetController().GoBack();
475 string16 actual_title = title_watcher.WaitAndGetTitle(); 475 base::string16 actual_title = title_watcher.WaitAndGetTitle();
476 EXPECT_EQ(expected_title, actual_title); 476 EXPECT_EQ(expected_title, actual_title);
477 EXPECT_EQ(3, GetCurrentIndex()); 477 EXPECT_EQ(3, GetCurrentIndex());
478 screenshot_manager()->WaitUntilScreenshotIsReady(); 478 screenshot_manager()->WaitUntilScreenshotIsReady();
479 entry = NavigationEntryImpl::FromNavigationEntry( 479 entry = NavigationEntryImpl::FromNavigationEntry(
480 web_contents->GetController().GetEntryAtIndex(4)); 480 web_contents->GetController().GetEntryAtIndex(4));
481 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry)); 481 EXPECT_TRUE(screenshot_manager()->ScreenshotSetForEntry(entry));
482 } 482 }
483 } 483 }
484 484
485 // Tests that screenshot is taken correctly when navigation causes a 485 // Tests that screenshot is taken correctly when navigation causes a
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 EXPECT_EQ(base::ASCIIToUTF16("Title: #1"), web_contents->GetTitle()); 634 EXPECT_EQ(base::ASCIIToUTF16("Title: #1"), web_contents->GetTitle());
635 EXPECT_TRUE(controller.CanGoBack()); 635 EXPECT_TRUE(controller.CanGoBack());
636 EXPECT_TRUE(controller.CanGoForward()); 636 EXPECT_TRUE(controller.CanGoForward());
637 637
638 aura::Window* content = web_contents->GetView()->GetContentNativeView(); 638 aura::Window* content = web_contents->GetView()->GetContentNativeView();
639 gfx::Rect bounds = content->GetBoundsInRootWindow(); 639 gfx::Rect bounds = content->GetBoundsInRootWindow();
640 aura::test::EventGenerator generator(content->GetRootWindow(), content); 640 aura::test::EventGenerator generator(content->GetRootWindow(), content);
641 641
642 // Do a swipe left to start a forward navigation. Then quickly do a swipe 642 // Do a swipe left to start a forward navigation. Then quickly do a swipe
643 // right. 643 // right.
644 string16 expected_title = ASCIIToUTF16("Title: #2"); 644 base::string16 expected_title = ASCIIToUTF16("Title: #2");
645 content::TitleWatcher title_watcher(web_contents, expected_title); 645 content::TitleWatcher title_watcher(web_contents, expected_title);
646 NavigationWatcher nav_watcher(web_contents); 646 NavigationWatcher nav_watcher(web_contents);
647 647
648 generator.GestureScrollSequence( 648 generator.GestureScrollSequence(
649 gfx::Point(bounds.right() - 10, bounds.y() + 10), 649 gfx::Point(bounds.right() - 10, bounds.y() + 10),
650 gfx::Point(bounds.x() + 2, bounds.y() + 10), 650 gfx::Point(bounds.x() + 2, bounds.y() + 10),
651 base::TimeDelta::FromMilliseconds(2000), 651 base::TimeDelta::FromMilliseconds(2000),
652 10); 652 10);
653 nav_watcher.WaitUntilNavigationStarts(); 653 nav_watcher.WaitUntilNavigationStarts();
654 654
655 generator.GestureScrollSequence( 655 generator.GestureScrollSequence(
656 gfx::Point(bounds.x() + 2, bounds.y() + 10), 656 gfx::Point(bounds.x() + 2, bounds.y() + 10),
657 gfx::Point(bounds.right() - 10, bounds.y() + 10), 657 gfx::Point(bounds.right() - 10, bounds.y() + 10),
658 base::TimeDelta::FromMilliseconds(2000), 658 base::TimeDelta::FromMilliseconds(2000),
659 10); 659 10);
660 string16 actual_title = title_watcher.WaitAndGetTitle(); 660 base::string16 actual_title = title_watcher.WaitAndGetTitle();
661 EXPECT_EQ(expected_title, actual_title); 661 EXPECT_EQ(expected_title, actual_title);
662 662
663 EXPECT_EQ(2, GetCurrentIndex()); 663 EXPECT_EQ(2, GetCurrentIndex());
664 EXPECT_TRUE(controller.CanGoBack()); 664 EXPECT_TRUE(controller.CanGoBack());
665 EXPECT_FALSE(controller.CanGoForward()); 665 EXPECT_FALSE(controller.CanGoForward());
666 } 666 }
667 667
668 } // namespace content 668 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.cc ('k') | content/browser/web_contents/web_contents_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698