OLD | NEW |
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/ui/webui/html_dialog_tab_contents_delegate.h" | 5 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 protected: | 50 protected: |
51 scoped_ptr<TestTabContentsDelegate> test_tab_contents_delegate_; | 51 scoped_ptr<TestTabContentsDelegate> test_tab_contents_delegate_; |
52 }; | 52 }; |
53 | 53 |
54 TEST_F(HtmlDialogTabContentsDelegateTest, DoNothingMethodsTest) { | 54 TEST_F(HtmlDialogTabContentsDelegateTest, DoNothingMethodsTest) { |
55 // None of the following calls should do anything. | 55 // None of the following calls should do anything. |
56 EXPECT_TRUE(test_tab_contents_delegate_->IsPopup(NULL)); | 56 EXPECT_TRUE(test_tab_contents_delegate_->IsPopup(NULL)); |
57 scoped_refptr<history::HistoryAddPageArgs> should_add_args( | 57 scoped_refptr<history::HistoryAddPageArgs> should_add_args( |
58 new history::HistoryAddPageArgs( | 58 new history::HistoryAddPageArgs( |
59 GURL(), base::Time::Now(), 0, 0, GURL(), history::RedirectList(), | 59 GURL(), base::Time::Now(), 0, 0, GURL(), history::RedirectList(), |
60 PageTransition::TYPED, history::SOURCE_SYNCED, false)); | 60 content::PAGE_TRANSITION_TYPED, history::SOURCE_SYNCED, false)); |
61 EXPECT_FALSE(test_tab_contents_delegate_->ShouldAddNavigationToHistory( | 61 EXPECT_FALSE(test_tab_contents_delegate_->ShouldAddNavigationToHistory( |
62 *should_add_args, NavigationType::NEW_PAGE)); | 62 *should_add_args, NavigationType::NEW_PAGE)); |
63 test_tab_contents_delegate_->NavigationStateChanged(NULL, 0); | 63 test_tab_contents_delegate_->NavigationStateChanged(NULL, 0); |
64 test_tab_contents_delegate_->ActivateContents(NULL); | 64 test_tab_contents_delegate_->ActivateContents(NULL); |
65 test_tab_contents_delegate_->LoadingStateChanged(NULL); | 65 test_tab_contents_delegate_->LoadingStateChanged(NULL); |
66 test_tab_contents_delegate_->CloseContents(NULL); | 66 test_tab_contents_delegate_->CloseContents(NULL); |
67 test_tab_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); | 67 test_tab_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); |
68 test_tab_contents_delegate_->MoveContents(NULL, gfx::Rect()); | 68 test_tab_contents_delegate_->MoveContents(NULL, gfx::Rect()); |
69 EXPECT_EQ(0, browser()->tab_count()); | 69 EXPECT_EQ(0, browser()->tab_count()); |
70 EXPECT_EQ(1U, BrowserList::size()); | 70 EXPECT_EQ(1U, BrowserList::size()); |
71 } | 71 } |
72 | 72 |
73 TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { | 73 TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { |
74 test_tab_contents_delegate_->OpenURLFromTab( | 74 test_tab_contents_delegate_->OpenURLFromTab( |
75 NULL, GURL(chrome::kAboutBlankURL), GURL(), | 75 NULL, GURL(chrome::kAboutBlankURL), GURL(), |
76 NEW_FOREGROUND_TAB, PageTransition::LINK); | 76 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
77 // This should create a new foreground tab in the existing browser. | 77 // This should create a new foreground tab in the existing browser. |
78 EXPECT_EQ(1, browser()->tab_count()); | 78 EXPECT_EQ(1, browser()->tab_count()); |
79 EXPECT_EQ(1U, BrowserList::size()); | 79 EXPECT_EQ(1U, BrowserList::size()); |
80 } | 80 } |
81 | 81 |
82 TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { | 82 TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { |
83 TabContents* contents = | 83 TabContents* contents = |
84 new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 84 new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
85 test_tab_contents_delegate_->AddNewContents( | 85 test_tab_contents_delegate_->AddNewContents( |
86 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); | 86 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); |
87 // This should create a new foreground tab in the existing browser. | 87 // This should create a new foreground tab in the existing browser. |
88 EXPECT_EQ(1, browser()->tab_count()); | 88 EXPECT_EQ(1, browser()->tab_count()); |
89 EXPECT_EQ(1U, BrowserList::size()); | 89 EXPECT_EQ(1U, BrowserList::size()); |
90 } | 90 } |
91 | 91 |
92 TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) { | 92 TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) { |
93 EXPECT_EQ(profile(), test_tab_contents_delegate_->profile()); | 93 EXPECT_EQ(profile(), test_tab_contents_delegate_->profile()); |
94 test_tab_contents_delegate_->Detach(); | 94 test_tab_contents_delegate_->Detach(); |
95 EXPECT_EQ(NULL, test_tab_contents_delegate_->profile()); | 95 EXPECT_EQ(NULL, test_tab_contents_delegate_->profile()); |
96 // Now, none of the following calls should do anything. | 96 // Now, none of the following calls should do anything. |
97 test_tab_contents_delegate_->OpenURLFromTab( | 97 test_tab_contents_delegate_->OpenURLFromTab( |
98 NULL, GURL(chrome::kAboutBlankURL), GURL(), | 98 NULL, GURL(chrome::kAboutBlankURL), GURL(), |
99 NEW_FOREGROUND_TAB, PageTransition::LINK); | 99 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
100 test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, | 100 test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, |
101 gfx::Rect(), false); | 101 gfx::Rect(), false); |
102 EXPECT_EQ(0, browser()->tab_count()); | 102 EXPECT_EQ(0, browser()->tab_count()); |
103 EXPECT_EQ(1U, BrowserList::size()); | 103 EXPECT_EQ(1U, BrowserList::size()); |
104 } | 104 } |
105 | 105 |
106 } // namespace | 106 } // namespace |
OLD | NEW |