| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer_host/test_render_view_host.h" | 5 #include "chrome/browser/renderer_host/test_render_view_host.h" |
| 6 #include "chrome/common/url_constants.h" | 6 #include "chrome/common/url_constants.h" |
| 7 | 7 |
| 8 typedef RenderViewHostTestHarness FindBackendTest; | 8 typedef RenderViewHostTestHarness FindBackendTest; |
| 9 | 9 |
| 10 // This test takes two TabContents objects, searches in both of them and | 10 // This test takes two TabContents objects, searches in both of them and |
| 11 // tests the internal state for find_text and find_prepopulate_text. | 11 // tests the internal state for find_text and find_prepopulate_text. |
| 12 TEST_F(FindBackendTest, InternalState) { | 12 TEST_F(FindBackendTest, InternalState) { |
| 13 // Initial state for the TabContents is blank strings. | 13 // Initial state for the TabContents is blank strings. |
| 14 EXPECT_EQ(string16(), contents()->find_prepopulate_text()); | 14 EXPECT_EQ(string16(), contents()->find_prepopulate_text()); |
| 15 EXPECT_EQ(string16(), contents()->find_text()); | 15 EXPECT_EQ(string16(), contents()->find_text()); |
| 16 | 16 |
| 17 // Get another TabContents object ready. | 17 // Get another TabContents object ready. |
| 18 TestTabContents contents2(profile_.get(), NULL); | 18 TestTabContents contents2(profile_.get(), NULL); |
| 19 | 19 |
| 20 // No search has still been issued, strings should be blank. | 20 // No search has still been issued, strings should be blank. |
| 21 EXPECT_EQ(string16(), contents()->find_prepopulate_text()); | 21 EXPECT_EQ(string16(), contents()->find_prepopulate_text()); |
| 22 EXPECT_EQ(string16(), contents()->find_text()); | 22 EXPECT_EQ(string16(), contents()->find_text()); |
| 23 EXPECT_EQ(string16(), contents2.find_prepopulate_text()); | 23 EXPECT_EQ(string16(), contents2.find_prepopulate_text()); |
| 24 EXPECT_EQ(string16(), contents2.find_text()); | 24 EXPECT_EQ(string16(), contents2.find_text()); |
| 25 | 25 |
| 26 string16 search_term1 = L" I had a 401K "; | 26 string16 search_term1 = ASCIIToUTF16(" I had a 401K "); |
| 27 string16 search_term2 = L" but the economy "; | 27 string16 search_term2 = ASCIIToUTF16(" but the economy "); |
| 28 string16 search_term3 = L" eated it. "; | 28 string16 search_term3 = ASCIIToUTF16(" eated it. "); |
| 29 | 29 |
| 30 // Start searching in the first TabContents, searching forwards but not case | 30 // Start searching in the first TabContents, searching forwards but not case |
| 31 // sensitive (as indicated by the last two params). | 31 // sensitive (as indicated by the last two params). |
| 32 contents()->StartFinding(search_term1, true, false); | 32 contents()->StartFinding(search_term1, true, false); |
| 33 | 33 |
| 34 // Pre-populate string should always match between the two, but find_text | 34 // Pre-populate string should always match between the two, but find_text |
| 35 // should not. | 35 // should not. |
| 36 EXPECT_EQ(search_term1, contents()->find_prepopulate_text()); | 36 EXPECT_EQ(search_term1, contents()->find_prepopulate_text()); |
| 37 EXPECT_EQ(search_term1, contents()->find_text()); | 37 EXPECT_EQ(search_term1, contents()->find_text()); |
| 38 EXPECT_EQ(search_term1, contents2.find_prepopulate_text()); | 38 EXPECT_EQ(search_term1, contents2.find_prepopulate_text()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 // sensitive (as indicated by the last two params). | 53 // sensitive (as indicated by the last two params). |
| 54 contents()->StartFinding(search_term3, true, false); | 54 contents()->StartFinding(search_term3, true, false); |
| 55 | 55 |
| 56 // Once more, pre-populate string should always match between the two, but | 56 // Once more, pre-populate string should always match between the two, but |
| 57 // find_text should not. | 57 // find_text should not. |
| 58 EXPECT_EQ(search_term3, contents()->find_prepopulate_text()); | 58 EXPECT_EQ(search_term3, contents()->find_prepopulate_text()); |
| 59 EXPECT_EQ(search_term3, contents()->find_text()); | 59 EXPECT_EQ(search_term3, contents()->find_text()); |
| 60 EXPECT_EQ(search_term3, contents2.find_prepopulate_text()); | 60 EXPECT_EQ(search_term3, contents2.find_prepopulate_text()); |
| 61 EXPECT_EQ(search_term2, contents2.find_text()); | 61 EXPECT_EQ(search_term2, contents2.find_text()); |
| 62 } | 62 } |
| OLD | NEW |