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

Side by Side Diff: chrome/browser/tab_contents/navigation_controller_unittest.cc

Issue 5716003: View source after POST command isn't what you expected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewers comments addressed. Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 EXPECT_EQ(url3, nav_params.a.url); 1858 EXPECT_EQ(url3, nav_params.a.url);
1859 process()->sink().ClearMessages(); 1859 process()->sink().ClearMessages();
1860 1860
1861 // Make sure an extravagant history.go() doesn't break. 1861 // Make sure an extravagant history.go() doesn't break.
1862 rvh_delegate->GoToEntryAtOffset(120); // Out of bounds. 1862 rvh_delegate->GoToEntryAtOffset(120); // Out of bounds.
1863 EXPECT_EQ(-1, controller().pending_entry_index()); 1863 EXPECT_EQ(-1, controller().pending_entry_index());
1864 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID); 1864 message = process()->sink().GetFirstMessageMatching(ViewMsg_Navigate::ID);
1865 EXPECT_TRUE(message == NULL); 1865 EXPECT_TRUE(message == NULL);
1866 } 1866 }
1867 1867
1868 // Test call to PruneAllButActive for the only entry.
1869 TEST_F(NavigationControllerTest, PruneAllButActiveForSingle) {
1870 const GURL url1("http://foo1");
1871 NavigateAndCommit(url1);
1872 controller().PruneAllButActive();
1873
1874 EXPECT_EQ(-1, controller().pending_entry_index());
1875 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1);
1876 }
1877
1878 // Test call to PruneAllButActive for last entry.
1879 TEST_F(NavigationControllerTest, PruneAllButActiveForLast) {
1880 const GURL url1("http://foo1");
1881 const GURL url2("http://foo2");
1882 const GURL url3("http://foo3");
1883
1884 NavigateAndCommit(url1);
1885 NavigateAndCommit(url2);
1886 NavigateAndCommit(url3);
1887 controller().GoBack();
1888 controller().GoBack();
1889 contents()->CommitPendingNavigation();
1890
1891 controller().PruneAllButActive();
1892
1893 EXPECT_EQ(-1, controller().pending_entry_index());
1894 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url1);
1895 }
1896
1897 // Test call to PruneAllButActive for intermediate entry.
1898 TEST_F(NavigationControllerTest, PruneAllButActiveForIntermediate) {
1899 const GURL url1("http://foo1");
1900 const GURL url2("http://foo2");
1901 const GURL url3("http://foo3");
1902
1903 NavigateAndCommit(url1);
1904 NavigateAndCommit(url2);
1905 NavigateAndCommit(url3);
1906 controller().GoBack();
1907 contents()->CommitPendingNavigation();
1908
1909 controller().PruneAllButActive();
1910
1911 EXPECT_EQ(-1, controller().pending_entry_index());
1912 EXPECT_EQ(controller().GetEntryAtIndex(0)->url(), url2);
1913 }
1914
1915 // Test call to PruneAllButActive for intermediate entry.
1916 TEST_F(NavigationControllerTest, PruneAllButActiveForPending) {
1917 const GURL url1("http://foo1");
1918 const GURL url2("http://foo2");
1919 const GURL url3("http://foo3");
1920
1921 NavigateAndCommit(url1);
1922 NavigateAndCommit(url2);
1923 NavigateAndCommit(url3);
1924 controller().GoBack();
1925
1926 controller().PruneAllButActive();
1927
1928 EXPECT_EQ(0, controller().pending_entry_index());
1929 }
1930
1931 // Test call to PruneAllButActive for transient entry.
1932 TEST_F(NavigationControllerTest, PruneAllButActiveForTransient) {
1933 const GURL url0("http://foo0");
1934 const GURL url1("http://foo1");
1935 const GURL transient_url("http://transient");
1936
1937 controller().LoadURL(url0, GURL(), PageTransition::TYPED);
1938 rvh()->SendNavigate(0, url0);
1939 controller().LoadURL(url1, GURL(), PageTransition::TYPED);
1940 rvh()->SendNavigate(1, url1);
1941
1942 // Adding a transient with no pending entry.
1943 NavigationEntry* transient_entry = new NavigationEntry;
1944 transient_entry->set_url(transient_url);
1945 controller().AddTransientEntry(transient_entry);
1946
1947 controller().PruneAllButActive();
1948
1949 EXPECT_EQ(-1, controller().pending_entry_index());
1950 EXPECT_EQ(-1, controller().pending_entry_index());
1951 EXPECT_EQ(controller().GetTransientEntry()->url(), transient_url);
1952 }
1953
1868 /* TODO(brettw) These test pass on my local machine but fail on the XP buildbot 1954 /* TODO(brettw) These test pass on my local machine but fail on the XP buildbot
Paweł Hajdan Jr. 2010/12/15 08:26:22 Could you DISABLE the tests below instead of havin
pfeldman1 2010/12/15 11:29:59 I don't see how it relates to the change I am appl
1869 (but not Vista) cleaning up the directory after they run. 1955 (but not Vista) cleaning up the directory after they run.
1870 This should be fixed. 1956 This should be fixed.
1871 1957
1872 // A basic test case. Navigates to a single url, and make sure the history 1958 // A basic test case. Navigates to a single url, and make sure the history
1873 // db matches. 1959 // db matches.
1874 TEST_F(NavigationControllerHistoryTest, Basic) { 1960 TEST_F(NavigationControllerHistoryTest, Basic) {
1875 controller().LoadURL(url0, GURL(), PageTransition::LINK); 1961 controller().LoadURL(url0, GURL(), PageTransition::LINK);
1876 rvh()->SendNavigate(0, url0); 1962 rvh()->SendNavigate(0, url0);
1877 1963
1878 GetLastSession(); 1964 GetLastSession();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 PageTransition::LINK); 2026 PageTransition::LINK);
1941 session_helper_.AssertNavigationEquals(nav, 2027 session_helper_.AssertNavigationEquals(nav,
1942 windows_[0]->tabs[0]->navigations[0]); 2028 windows_[0]->tabs[0]->navigations[0]);
1943 nav.set_url(url2); 2029 nav.set_url(url2);
1944 session_helper_.AssertNavigationEquals(nav, 2030 session_helper_.AssertNavigationEquals(nav,
1945 windows_[0]->tabs[0]->navigations[1]); 2031 windows_[0]->tabs[0]->navigations[1]);
1946 } 2032 }
1947 */ 2033 */
1948 2034
1949 } // namespace 2035 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/navigation_controller.cc ('k') | chrome/browser/tab_contents/render_view_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698