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 "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_tab_helper.h" | 9 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // This test takes two TabContents objects, searches in both of them and | 36 // This test takes two TabContents objects, searches in both of them and |
37 // tests the internal state for find_text and find_prepopulate_text. | 37 // tests the internal state for find_text and find_prepopulate_text. |
38 TEST_F(FindBackendTest, InternalState) { | 38 TEST_F(FindBackendTest, InternalState) { |
39 FindTabHelper* find_tab_helper = contents_wrapper()->find_tab_helper(); | 39 FindTabHelper* find_tab_helper = contents_wrapper()->find_tab_helper(); |
40 // Initial state for the TabContents is blank strings. | 40 // Initial state for the TabContents is blank strings. |
41 EXPECT_EQ(string16(), FindPrepopulateText(contents())); | 41 EXPECT_EQ(string16(), FindPrepopulateText(contents())); |
42 EXPECT_EQ(string16(), find_tab_helper->find_text()); | 42 EXPECT_EQ(string16(), find_tab_helper->find_text()); |
43 | 43 |
44 // Get another TabContents object ready. | 44 // Get another TabContents object ready. |
45 TestTabContents* contents2 = new TestTabContents(profile_.get(), NULL); | 45 TestTabContents* contents2 = new TestTabContents(profile(), NULL); |
46 TabContentsWrapper wrapper2(contents2); | 46 TabContentsWrapper wrapper2(contents2); |
47 FindTabHelper* find_tab_helper2 = wrapper2.find_tab_helper(); | 47 FindTabHelper* find_tab_helper2 = wrapper2.find_tab_helper(); |
48 | 48 |
49 // No search has still been issued, strings should be blank. | 49 // No search has still been issued, strings should be blank. |
50 EXPECT_EQ(string16(), FindPrepopulateText(contents())); | 50 EXPECT_EQ(string16(), FindPrepopulateText(contents())); |
51 EXPECT_EQ(string16(), find_tab_helper->find_text()); | 51 EXPECT_EQ(string16(), find_tab_helper->find_text()); |
52 EXPECT_EQ(string16(), FindPrepopulateText(contents2)); | 52 EXPECT_EQ(string16(), FindPrepopulateText(contents2)); |
53 EXPECT_EQ(string16(), find_tab_helper2->find_text()); | 53 EXPECT_EQ(string16(), find_tab_helper2->find_text()); |
54 | 54 |
55 string16 search_term1 = ASCIIToUTF16(" I had a 401K "); | 55 string16 search_term1 = ASCIIToUTF16(" I had a 401K "); |
(...skipping 26 matching lines...) Expand all Loading... |
82 // find_tab_helper (as indicated by the last two params). | 82 // find_tab_helper (as indicated by the last two params). |
83 find_tab_helper->StartFinding(search_term3, true, false); | 83 find_tab_helper->StartFinding(search_term3, true, false); |
84 | 84 |
85 // Once more, pre-populate string should always match between the two, but | 85 // Once more, pre-populate string should always match between the two, but |
86 // find_text should not. | 86 // find_text should not. |
87 EXPECT_EQ(search_term3, FindPrepopulateText(contents())); | 87 EXPECT_EQ(search_term3, FindPrepopulateText(contents())); |
88 EXPECT_EQ(search_term3, find_tab_helper->find_text()); | 88 EXPECT_EQ(search_term3, find_tab_helper->find_text()); |
89 EXPECT_EQ(search_term3, FindPrepopulateText(contents2)); | 89 EXPECT_EQ(search_term3, FindPrepopulateText(contents2)); |
90 EXPECT_EQ(search_term2, find_tab_helper2->find_text()); | 90 EXPECT_EQ(search_term2, find_tab_helper2->find_text()); |
91 } | 91 } |
OLD | NEW |