| OLD | NEW |
| 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 "app/system_monitor.h" | 5 #include "app/system_monitor.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 TabStripModel strip(&delegate, profile()); | 1839 TabStripModel strip(&delegate, profile()); |
| 1840 | 1840 |
| 1841 TabContentsWrapper* first_contents = CreateTabContents(); | 1841 TabContentsWrapper* first_contents = CreateTabContents(); |
| 1842 strip.AddTabContents(first_contents, -1, PageTransition::TYPED, | 1842 strip.AddTabContents(first_contents, -1, PageTransition::TYPED, |
| 1843 TabStripModel::ADD_SELECTED); | 1843 TabStripModel::ADD_SELECTED); |
| 1844 | 1844 |
| 1845 MockTabStripModelObserver tabstrip_observer; | 1845 MockTabStripModelObserver tabstrip_observer; |
| 1846 strip.AddObserver(&tabstrip_observer); | 1846 strip.AddObserver(&tabstrip_observer); |
| 1847 | 1847 |
| 1848 TabContentsWrapper* new_contents = CreateTabContents(); | 1848 TabContentsWrapper* new_contents = CreateTabContents(); |
| 1849 strip.ReplaceTabContentsAt(0, new_contents); | 1849 delete strip.ReplaceTabContentsAt(0, new_contents); |
| 1850 | 1850 |
| 1851 ASSERT_EQ(2, tabstrip_observer.GetStateCount()); | 1851 ASSERT_EQ(2, tabstrip_observer.GetStateCount()); |
| 1852 | 1852 |
| 1853 // First event should be for replaced. | 1853 // First event should be for replaced. |
| 1854 State state(new_contents, 0, MockTabStripModelObserver::REPLACED); | 1854 State state(new_contents, 0, MockTabStripModelObserver::REPLACED); |
| 1855 state.src_contents = first_contents; | 1855 state.src_contents = first_contents; |
| 1856 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); | 1856 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); |
| 1857 | 1857 |
| 1858 // And the second for selected. | 1858 // And the second for selected. |
| 1859 state = State(new_contents, 0, MockTabStripModelObserver::SELECT); | 1859 state = State(new_contents, 0, MockTabStripModelObserver::SELECT); |
| 1860 state.src_contents = first_contents; | 1860 state.src_contents = first_contents; |
| 1861 EXPECT_TRUE(tabstrip_observer.StateEquals(1, state)); | 1861 EXPECT_TRUE(tabstrip_observer.StateEquals(1, state)); |
| 1862 | 1862 |
| 1863 // Now add another tab and replace it, making sure we don't get a selected | 1863 // Now add another tab and replace it, making sure we don't get a selected |
| 1864 // event this time. | 1864 // event this time. |
| 1865 TabContentsWrapper* third_contents = CreateTabContents(); | 1865 TabContentsWrapper* third_contents = CreateTabContents(); |
| 1866 strip.AddTabContents(third_contents, 1, PageTransition::TYPED, | 1866 strip.AddTabContents(third_contents, 1, PageTransition::TYPED, |
| 1867 TabStripModel::ADD_NONE); | 1867 TabStripModel::ADD_NONE); |
| 1868 | 1868 |
| 1869 tabstrip_observer.ClearStates(); | 1869 tabstrip_observer.ClearStates(); |
| 1870 | 1870 |
| 1871 // And replace it. | 1871 // And replace it. |
| 1872 new_contents = CreateTabContents(); | 1872 new_contents = CreateTabContents(); |
| 1873 strip.ReplaceTabContentsAt(1, new_contents); | 1873 delete strip.ReplaceTabContentsAt(1, new_contents); |
| 1874 | 1874 |
| 1875 ASSERT_EQ(1, tabstrip_observer.GetStateCount()); | 1875 ASSERT_EQ(1, tabstrip_observer.GetStateCount()); |
| 1876 | 1876 |
| 1877 state = State(new_contents, 1, MockTabStripModelObserver::REPLACED); | 1877 state = State(new_contents, 1, MockTabStripModelObserver::REPLACED); |
| 1878 state.src_contents = third_contents; | 1878 state.src_contents = third_contents; |
| 1879 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); | 1879 EXPECT_TRUE(tabstrip_observer.StateEquals(0, state)); |
| 1880 | 1880 |
| 1881 strip.CloseAllTabs(); | 1881 strip.CloseAllTabs(); |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 // Makes sure TabStripModel handles the case of deleting a tab while removing | 1884 // Makes sure TabStripModel handles the case of deleting a tab while removing |
| 1885 // another tab. | 1885 // another tab. |
| 1886 TEST_F(TabStripModelTest, DeleteFromDestroy) { | 1886 TEST_F(TabStripModelTest, DeleteFromDestroy) { |
| 1887 TabStripDummyDelegate delegate(NULL); | 1887 TabStripDummyDelegate delegate(NULL); |
| 1888 TabStripModel strip(&delegate, profile()); | 1888 TabStripModel strip(&delegate, profile()); |
| 1889 TabContentsWrapper* contents1 = CreateTabContents(); | 1889 TabContentsWrapper* contents1 = CreateTabContents(); |
| 1890 TabContentsWrapper* contents2 = CreateTabContents(); | 1890 TabContentsWrapper* contents2 = CreateTabContents(); |
| 1891 strip.AppendTabContents(contents1, true); | 1891 strip.AppendTabContents(contents1, true); |
| 1892 strip.AppendTabContents(contents2, true); | 1892 strip.AppendTabContents(contents2, true); |
| 1893 // DeleteTabContentsOnDestroyedObserver deletes contents1 when contents2 sends | 1893 // DeleteTabContentsOnDestroyedObserver deletes contents1 when contents2 sends |
| 1894 // out notification that it is being destroyed. | 1894 // out notification that it is being destroyed. |
| 1895 DeleteTabContentsOnDestroyedObserver observer(contents2, contents1); | 1895 DeleteTabContentsOnDestroyedObserver observer(contents2, contents1); |
| 1896 strip.CloseAllTabs(); | 1896 strip.CloseAllTabs(); |
| 1897 } | 1897 } |
| OLD | NEW |