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

Side by Side Diff: chrome/browser/tabs/tab_strip_model_unittest.cc

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 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) 2011 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 "chrome/browser/tabs/tab_strip_model.h" 5 #include "chrome/browser/tabs/tab_strip_model.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/public/browser/navigation_entry.h" 34 #include "content/public/browser/navigation_entry.h"
35 #include "content/public/browser/notification_details.h" 35 #include "content/public/browser/notification_details.h"
36 #include "content/public/browser/notification_registrar.h" 36 #include "content/public/browser/notification_registrar.h"
37 #include "content/public/browser/notification_source.h" 37 #include "content/public/browser/notification_source.h"
38 #include "content/public/browser/notification_types.h" 38 #include "content/public/browser/notification_types.h"
39 #include "content/test/notification_observer_mock.h" 39 #include "content/test/notification_observer_mock.h"
40 #include "content/test/test_browser_thread.h" 40 #include "content/test/test_browser_thread.h"
41 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
42 42
43 using content::BrowserThread; 43 using content::BrowserThread;
44 using content::NavigationController;
44 using content::WebContents; 45 using content::WebContents;
45 using testing::_; 46 using testing::_;
46 47
47 namespace { 48 namespace {
48 49
49 // Class used to delete a TabContents when another TabContents is destroyed. 50 // Class used to delete a TabContents when another TabContents is destroyed.
50 class DeleteTabContentsOnDestroyedObserver 51 class DeleteTabContentsOnDestroyedObserver
51 : public content::NotificationObserver { 52 : public content::NotificationObserver {
52 public: 53 public:
53 DeleteTabContentsOnDestroyedObserver(TabContentsWrapper* source, 54 DeleteTabContentsOnDestroyedObserver(TabContentsWrapper* source,
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 TEST_F(TabStripModelTest, TestBasicOpenerAPI) { 634 TEST_F(TabStripModelTest, TestBasicOpenerAPI) {
634 TabStripDummyDelegate delegate(NULL); 635 TabStripDummyDelegate delegate(NULL);
635 TabStripModel tabstrip(&delegate, profile()); 636 TabStripModel tabstrip(&delegate, profile());
636 EXPECT_TRUE(tabstrip.empty()); 637 EXPECT_TRUE(tabstrip.empty());
637 638
638 // This is a basic test of opener functionality. opener_contents is created 639 // This is a basic test of opener functionality. opener_contents is created
639 // as the first tab in the strip and then we create 5 other tabs in the 640 // as the first tab in the strip and then we create 5 other tabs in the
640 // background with opener_contents set as their opener. 641 // background with opener_contents set as their opener.
641 642
642 TabContentsWrapper* opener_contents = CreateTabContents(); 643 TabContentsWrapper* opener_contents = CreateTabContents();
643 content::NavigationController* opener = 644 NavigationController* opener =
644 &opener_contents->tab_contents()->GetController(); 645 &opener_contents->tab_contents()->GetController();
645 tabstrip.AppendTabContents(opener_contents, true); 646 tabstrip.AppendTabContents(opener_contents, true);
646 TabContentsWrapper* contents1 = CreateTabContents(); 647 TabContentsWrapper* contents1 = CreateTabContents();
647 TabContentsWrapper* contents2 = CreateTabContents(); 648 TabContentsWrapper* contents2 = CreateTabContents();
648 TabContentsWrapper* contents3 = CreateTabContents(); 649 TabContentsWrapper* contents3 = CreateTabContents();
649 TabContentsWrapper* contents4 = CreateTabContents(); 650 TabContentsWrapper* contents4 = CreateTabContents();
650 TabContentsWrapper* contents5 = CreateTabContents(); 651 TabContentsWrapper* contents5 = CreateTabContents();
651 652
652 // We use |InsertTabContentsAt| here instead of AppendTabContents so that 653 // We use |InsertTabContentsAt| here instead of AppendTabContents so that
653 // openership relationships are preserved. 654 // openership relationships are preserved.
(...skipping 18 matching lines...) Expand all
672 // group should be selected. 673 // group should be selected.
673 EXPECT_EQ(4, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 5, false)); 674 EXPECT_EQ(4, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 5, false));
674 675
675 // Tests the method that finds the last tab opened by the same opener in the 676 // Tests the method that finds the last tab opened by the same opener in the
676 // strip (this is the insertion index for the next background tab for the 677 // strip (this is the insertion index for the next background tab for the
677 // specified opener). 678 // specified opener).
678 EXPECT_EQ(5, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1)); 679 EXPECT_EQ(5, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1));
679 680
680 // For a tab that has opened no other tabs, the return value should always be 681 // For a tab that has opened no other tabs, the return value should always be
681 // -1... 682 // -1...
682 content::NavigationController* o1 = 683 NavigationController* o1 = &contents1->tab_contents()->GetController();
683 &contents1->tab_contents()->GetController();
684 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(o1, 3, false)); 684 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(o1, 3, false));
685 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(o1, 3)); 685 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(o1, 3));
686 686
687 // ForgetAllOpeners should destroy all opener relationships. 687 // ForgetAllOpeners should destroy all opener relationships.
688 tabstrip.ForgetAllOpeners(); 688 tabstrip.ForgetAllOpeners();
689 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 1, false)); 689 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 1, false));
690 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 5, false)); 690 EXPECT_EQ(-1, tabstrip.GetIndexOfNextTabContentsOpenedBy(opener, 5, false));
691 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1)); 691 EXPECT_EQ(-1, tabstrip.GetIndexOfLastTabContentsOpenedBy(opener, 1));
692 692
693 tabstrip.CloseAllTabs(); 693 tabstrip.CloseAllTabs();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // a new tab from the first tab in the foreground via a link click, verifies 786 // a new tab from the first tab in the foreground via a link click, verifies
787 // that this tab is opened adjacent to the opener, then closes it. 787 // that this tab is opened adjacent to the opener, then closes it.
788 // Finally it tests that a tab opened for some non-link purpose openes at the 788 // Finally it tests that a tab opened for some non-link purpose openes at the
789 // end of the strip, not bundled to any existing context. 789 // end of the strip, not bundled to any existing context.
790 TEST_F(TabStripModelTest, TestInsertionIndexDetermination) { 790 TEST_F(TabStripModelTest, TestInsertionIndexDetermination) {
791 TabStripDummyDelegate delegate(NULL); 791 TabStripDummyDelegate delegate(NULL);
792 TabStripModel tabstrip(&delegate, profile()); 792 TabStripModel tabstrip(&delegate, profile());
793 EXPECT_TRUE(tabstrip.empty()); 793 EXPECT_TRUE(tabstrip.empty());
794 794
795 TabContentsWrapper* opener_contents = CreateTabContents(); 795 TabContentsWrapper* opener_contents = CreateTabContents();
796 content::NavigationController* opener = 796 NavigationController* opener =
797 &opener_contents->tab_contents()->GetController(); 797 &opener_contents->tab_contents()->GetController();
798 tabstrip.AppendTabContents(opener_contents, true); 798 tabstrip.AppendTabContents(opener_contents, true);
799 799
800 // Open some other random unrelated tab in the background to monkey with our 800 // Open some other random unrelated tab in the background to monkey with our
801 // insertion index. 801 // insertion index.
802 TabContentsWrapper* other_contents = CreateTabContents(); 802 TabContentsWrapper* other_contents = CreateTabContents();
803 tabstrip.AppendTabContents(other_contents, false); 803 tabstrip.AppendTabContents(other_contents, false);
804 804
805 TabContentsWrapper* contents1 = CreateTabContents(); 805 TabContentsWrapper* contents1 = CreateTabContents();
806 TabContentsWrapper* contents2 = CreateTabContents(); 806 TabContentsWrapper* contents2 = CreateTabContents();
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 ASSERT_EQ(1, observer.GetStateCount()); 2381 ASSERT_EQ(1, observer.GetStateCount());
2382 MockTabStripModelObserver::State s( 2382 MockTabStripModelObserver::State s(
2383 contents2, 1, MockTabStripModelObserver::SELECT); 2383 contents2, 1, MockTabStripModelObserver::SELECT);
2384 s.src_contents = contents2; 2384 s.src_contents = contents2;
2385 s.src_index = 1; 2385 s.src_index = 1;
2386 s.user_gesture = false; 2386 s.user_gesture = false;
2387 EXPECT_TRUE(observer.StateEquals(0, s)); 2387 EXPECT_TRUE(observer.StateEquals(0, s));
2388 strip.RemoveObserver(&observer); 2388 strip.RemoveObserver(&observer);
2389 strip.CloseAllTabs(); 2389 strip.CloseAllTabs();
2390 } 2390 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model_order_controller.cc ('k') | chrome/browser/translate/translate_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698