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

Side by Side Diff: chrome/browser/ui/find_bar/find_backend_unittest.cc

Issue 10868072: Make TabContents ctor private; poke hole for existing callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all green Created 8 years, 3 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
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.cc ('k') | chrome/browser/ui/gtk/web_dialog_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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 "base/string16.h" 5 #include "base/string16.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/find_bar/find_bar_state.h" 8 #include "chrome/browser/ui/find_bar/find_bar_state.h"
9 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h" 9 #include "chrome/browser/ui/find_bar/find_bar_state_factory.h"
10 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 10 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
17 #include "content/public/test/web_contents_tester.h" 17 #include "content/public/test/web_contents_tester.h"
18 18
19 using content::BrowserThread; 19 using content::BrowserThread;
20 using content::WebContents; 20 using content::WebContents;
21 using content::WebContentsTester; 21 using content::WebContentsTester;
22 22
23 // TODO(avi): Kill this when TabContents goes away.
24 class FindBackendTestContentsCreator {
25 public:
26 static TabContents* CreateTabContents(content::WebContents* contents) {
27 return TabContents::Factory::CreateTabContents(contents);
28 }
29 };
30
23 class FindBackendTest : public TabContentsTestHarness { 31 class FindBackendTest : public TabContentsTestHarness {
24 public: 32 public:
25 FindBackendTest() 33 FindBackendTest()
26 : TabContentsTestHarness(), 34 : TabContentsTestHarness(),
27 browser_thread_(BrowserThread::UI, &message_loop_) {} 35 browser_thread_(BrowserThread::UI, &message_loop_) {}
28 36
29 private: 37 private:
30 content::TestBrowserThread browser_thread_; 38 content::TestBrowserThread browser_thread_;
31 }; 39 };
32 40
(...skipping 10 matching lines...) Expand all
43 // tests the internal state for find_text and find_prepopulate_text. 51 // tests the internal state for find_text and find_prepopulate_text.
44 TEST_F(FindBackendTest, InternalState) { 52 TEST_F(FindBackendTest, InternalState) {
45 FindTabHelper* find_tab_helper = tab_contents()->find_tab_helper(); 53 FindTabHelper* find_tab_helper = tab_contents()->find_tab_helper();
46 // Initial state for the WebContents is blank strings. 54 // Initial state for the WebContents is blank strings.
47 EXPECT_EQ(string16(), FindPrepopulateText(contents())); 55 EXPECT_EQ(string16(), FindPrepopulateText(contents()));
48 EXPECT_EQ(string16(), find_tab_helper->find_text()); 56 EXPECT_EQ(string16(), find_tab_helper->find_text());
49 57
50 // Get another WebContents object ready. 58 // Get another WebContents object ready.
51 WebContents* contents2 = 59 WebContents* contents2 =
52 WebContentsTester::CreateTestWebContents(profile(), NULL); 60 WebContentsTester::CreateTestWebContents(profile(), NULL);
53 TabContents tab_contents(contents2); 61 scoped_ptr<TabContents> tab_contents(
54 FindTabHelper* find_tab_helper2 = tab_contents.find_tab_helper(); 62 FindBackendTestContentsCreator::CreateTabContents(contents2));
63 FindTabHelper* find_tab_helper2 = tab_contents->find_tab_helper();
55 64
56 // No search has still been issued, strings should be blank. 65 // No search has still been issued, strings should be blank.
57 EXPECT_EQ(string16(), FindPrepopulateText(contents())); 66 EXPECT_EQ(string16(), FindPrepopulateText(contents()));
58 EXPECT_EQ(string16(), find_tab_helper->find_text()); 67 EXPECT_EQ(string16(), find_tab_helper->find_text());
59 EXPECT_EQ(string16(), FindPrepopulateText(contents2)); 68 EXPECT_EQ(string16(), FindPrepopulateText(contents2));
60 EXPECT_EQ(string16(), find_tab_helper2->find_text()); 69 EXPECT_EQ(string16(), find_tab_helper2->find_text());
61 70
62 string16 search_term1 = ASCIIToUTF16(" I had a 401K "); 71 string16 search_term1 = ASCIIToUTF16(" I had a 401K ");
63 string16 search_term2 = ASCIIToUTF16(" but the economy "); 72 string16 search_term2 = ASCIIToUTF16(" but the economy ");
64 string16 search_term3 = ASCIIToUTF16(" eated it. "); 73 string16 search_term3 = ASCIIToUTF16(" eated it. ");
(...skipping 24 matching lines...) Expand all
89 // find_tab_helper (as indicated by the last two params). 98 // find_tab_helper (as indicated by the last two params).
90 find_tab_helper->StartFinding(search_term3, true, false); 99 find_tab_helper->StartFinding(search_term3, true, false);
91 100
92 // Once more, pre-populate string should always match between the two, but 101 // Once more, pre-populate string should always match between the two, but
93 // find_text should not. 102 // find_text should not.
94 EXPECT_EQ(search_term3, FindPrepopulateText(contents())); 103 EXPECT_EQ(search_term3, FindPrepopulateText(contents()));
95 EXPECT_EQ(search_term3, find_tab_helper->find_text()); 104 EXPECT_EQ(search_term3, find_tab_helper->find_text());
96 EXPECT_EQ(search_term3, FindPrepopulateText(contents2)); 105 EXPECT_EQ(search_term3, FindPrepopulateText(contents2));
97 EXPECT_EQ(search_term2, find_tab_helper2->find_text()); 106 EXPECT_EQ(search_term2, find_tab_helper2->find_text());
98 } 107 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/shell_window.cc ('k') | chrome/browser/ui/gtk/web_dialog_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698