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

Side by Side Diff: chrome/browser/session_history_uitest.cc

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/string_util.h" 5 #include "base/string_util.h"
6 #include "base/utf_string_conversions.h"
6 #include "chrome/common/url_constants.h" 7 #include "chrome/common/url_constants.h"
7 #include "chrome/test/automation/tab_proxy.h" 8 #include "chrome/test/automation/tab_proxy.h"
8 #include "chrome/test/automation/browser_proxy.h" 9 #include "chrome/test/automation/browser_proxy.h"
9 #include "chrome/test/ui/ui_test.h" 10 #include "chrome/test/ui/ui_test.h"
10 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
11 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
12 #include "net/test/test_server.h" 13 #include "net/test/test_server.h"
13 14
14 namespace { 15 namespace {
15 16
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ASSERT_TRUE(tab_->NavigateToURL(url)); 55 ASSERT_TRUE(tab_->NavigateToURL(url));
55 } 56 }
56 57
57 // Navigate session history using history.go(distance). 58 // Navigate session history using history.go(distance).
58 void JavascriptGo(std::string distance) { 59 void JavascriptGo(std::string distance) {
59 GURL url("javascript:history.go('" + distance + "')"); 60 GURL url("javascript:history.go('" + distance + "')");
60 ASSERT_TRUE(tab_->NavigateToURL(url)); 61 ASSERT_TRUE(tab_->NavigateToURL(url));
61 } 62 }
62 63
63 std::wstring GetTabTitle() { 64 std::wstring GetTabTitle() {
64 std::wstring title; 65 string16 title;
65 EXPECT_TRUE(tab_->GetTabTitle(&title)); 66 EXPECT_TRUE(tab_->GetTabTitle(&title));
66 return title; 67 return UTF16ToWideHack(title);
67 } 68 }
68 69
69 GURL GetTabURL() { 70 GURL GetTabURL() {
70 GURL url; 71 GURL url;
71 EXPECT_TRUE(tab_->GetCurrentURL(&url)); 72 EXPECT_TRUE(tab_->GetCurrentURL(&url));
72 return url; 73 return url;
73 } 74 }
74 75
75 protected: 76 protected:
76 scoped_refptr<BrowserProxy> window_; 77 scoped_refptr<BrowserProxy> window_;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 ASSERT_TRUE(tab_->GoBack()); 529 ASSERT_TRUE(tab_->GoBack());
529 EXPECT_EQ(L"Default Title", GetTabTitle()); 530 EXPECT_EQ(L"Default Title", GetTabTitle());
530 } 531 }
531 532
532 // http://code.google.com/p/chromium/issues/detail?id=56267 533 // http://code.google.com/p/chromium/issues/detail?id=56267
533 TEST_F(SessionHistoryTest, DISABLED_HistoryLength) { 534 TEST_F(SessionHistoryTest, DISABLED_HistoryLength) {
534 ASSERT_TRUE(test_server_.Start()); 535 ASSERT_TRUE(test_server_.Start());
535 536
536 int length; 537 int length;
537 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 538 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
538 L"", L"domAutomationController.send(history.length)", &length)); 539 string16(),
540 ASCIIToUTF16("domAutomationController.send(history.length)"),
541 &length));
539 EXPECT_EQ(1, length); 542 EXPECT_EQ(1, length);
540 543
541 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title1.html"))); 544 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title1.html")));
542 545
543 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 546 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
544 L"", L"domAutomationController.send(history.length)", &length)); 547 string16(),
548 ASCIIToUTF16("domAutomationController.send(history.length)"),
549 &length));
545 EXPECT_EQ(2, length); 550 EXPECT_EQ(2, length);
546 551
547 // Now test that history.length is updated when the navigation is committed. 552 // Now test that history.length is updated when the navigation is committed.
548 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL( 553 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL(
549 "files/session_history/record_length.html"))); 554 "files/session_history/record_length.html")));
550 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 555 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
551 L"", L"domAutomationController.send(history.length)", &length)); 556 string16(),
557 ASCIIToUTF16("domAutomationController.send(history.length)"),
558 &length));
552 EXPECT_EQ(3, length); 559 EXPECT_EQ(3, length);
553 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 560 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
554 L"", L"domAutomationController.send(history_length)", &length)); 561 string16(),
562 ASCIIToUTF16("domAutomationController.send(history_length)"),
563 &length));
555 EXPECT_EQ(3, length); 564 EXPECT_EQ(3, length);
556 565
557 ASSERT_TRUE(tab_->GoBack()); 566 ASSERT_TRUE(tab_->GoBack());
558 ASSERT_TRUE(tab_->GoBack()); 567 ASSERT_TRUE(tab_->GoBack());
559 568
560 // Ensure history.length is properly truncated. 569 // Ensure history.length is properly truncated.
561 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title2.html"))); 570 ASSERT_TRUE(tab_->NavigateToURL(test_server_.GetURL("files/title2.html")));
562 ASSERT_TRUE(tab_->ExecuteAndExtractInt( 571 ASSERT_TRUE(tab_->ExecuteAndExtractInt(
563 L"", L"domAutomationController.send(history.length)", &length)); 572 string16(),
573 ASCIIToUTF16("domAutomationController.send(history.length)"),
574 &length));
564 EXPECT_EQ(2, length); 575 EXPECT_EQ(2, length);
565 } 576 }
566 577
567 } // namespace 578 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698