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

Side by Side Diff: chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc

Issue 9706012: Add abstractions that let embedders drive tests of WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove CONTENT_EXPORT on statically linked functions. Merge to head for commit. Created 8 years, 9 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) 2012 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"
11 #include "chrome/browser/history/history_types.h" 11 #include "chrome/browser/history/history_types.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/browser_with_test_window_test.h" 15 #include "chrome/test/base/browser_with_test_window_test.h"
16 #include "chrome/test/base/test_browser_window.h" 16 #include "chrome/test/base/test_browser_window.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/browser/tab_contents/test_tab_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/test/web_contents_tester.h"
19 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
23 24
24 using content::OpenURLParams; 25 using content::OpenURLParams;
25 using content::Referrer; 26 using content::Referrer;
27 using content::WebContents;
28 using content::WebContentsTester;
26 29
27 namespace { 30 namespace {
28 31
29 class TestTabContentsDelegate : public HtmlDialogTabContentsDelegate { 32 class TestTabContentsDelegate : public HtmlDialogTabContentsDelegate {
30 public: 33 public:
31 explicit TestTabContentsDelegate(Profile* profile) 34 explicit TestTabContentsDelegate(Profile* profile)
32 : HtmlDialogTabContentsDelegate(profile) {} 35 : HtmlDialogTabContentsDelegate(profile) {}
33 36
34 virtual ~TestTabContentsDelegate() { 37 virtual ~TestTabContentsDelegate() {
35 } 38 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { 79 TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) {
77 test_tab_contents_delegate_->OpenURLFromTab( 80 test_tab_contents_delegate_->OpenURLFromTab(
78 NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), 81 NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(),
79 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); 82 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false));
80 // This should create a new foreground tab in the existing browser. 83 // This should create a new foreground tab in the existing browser.
81 EXPECT_EQ(1, browser()->tab_count()); 84 EXPECT_EQ(1, browser()->tab_count());
82 EXPECT_EQ(1U, BrowserList::size()); 85 EXPECT_EQ(1U, BrowserList::size());
83 } 86 }
84 87
85 TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { 88 TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) {
86 TabContents* contents = 89 WebContents* contents =
87 new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); 90 WebContentsTester::CreateTestWebContents(profile(), NULL);
88 test_tab_contents_delegate_->AddNewContents( 91 test_tab_contents_delegate_->AddNewContents(
89 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); 92 NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false);
90 // This should create a new foreground tab in the existing browser. 93 // This should create a new foreground tab in the existing browser.
91 EXPECT_EQ(1, browser()->tab_count()); 94 EXPECT_EQ(1, browser()->tab_count());
92 EXPECT_EQ(1U, BrowserList::size()); 95 EXPECT_EQ(1U, BrowserList::size());
93 } 96 }
94 97
95 TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) { 98 TEST_F(HtmlDialogTabContentsDelegateTest, DetachTest) {
96 EXPECT_EQ(profile(), test_tab_contents_delegate_->profile()); 99 EXPECT_EQ(profile(), test_tab_contents_delegate_->profile());
97 test_tab_contents_delegate_->Detach(); 100 test_tab_contents_delegate_->Detach();
98 EXPECT_EQ(NULL, test_tab_contents_delegate_->profile()); 101 EXPECT_EQ(NULL, test_tab_contents_delegate_->profile());
99 // Now, none of the following calls should do anything. 102 // Now, none of the following calls should do anything.
100 test_tab_contents_delegate_->OpenURLFromTab( 103 test_tab_contents_delegate_->OpenURLFromTab(
101 NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(), 104 NULL, OpenURLParams(GURL(chrome::kAboutBlankURL), Referrer(),
102 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false)); 105 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false));
103 test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB, 106 test_tab_contents_delegate_->AddNewContents(NULL, NULL, NEW_FOREGROUND_TAB,
104 gfx::Rect(), false); 107 gfx::Rect(), false);
105 EXPECT_EQ(0, browser()->tab_count()); 108 EXPECT_EQ(0, browser()->tab_count());
106 EXPECT_EQ(1U, BrowserList::size()); 109 EXPECT_EQ(1U, BrowserList::size());
107 } 110 }
108 111
109 } // namespace 112 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/stubs_aura.cc ('k') | chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698