summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-15 03:54:32 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-15 03:54:32 +0000
commit39a1d710b25cafea4fcc655778cb19e8ad0bd1f7 (patch)
tree9c5637cb2971c7ec1711a40c8b20921e4789d823 /chrome
parent1cf92c0dbefbbb2e832afed35f8228ec8131899d (diff)
downloadchromium_src-39a1d710b25cafea4fcc655778cb19e8ad0bd1f7.zip
chromium_src-39a1d710b25cafea4fcc655778cb19e8ad0bd1f7.tar.gz
chromium_src-39a1d710b25cafea4fcc655778cb19e8ad0bd1f7.tar.bz2
Adding a unit test for testing the prepopulation text during search.
Review URL: http://codereview.chromium.org/73059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/find_backend_unittest.cc64
-rw-r--r--chrome/test/unit/unittests.vcproj4
2 files changed, 68 insertions, 0 deletions
diff --git a/chrome/browser/find_backend_unittest.cc b/chrome/browser/find_backend_unittest.cc
new file mode 100644
index 0000000..2a2dba4
--- /dev/null
+++ b/chrome/browser/find_backend_unittest.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/common/url_constants.h"
+
+typedef RenderViewHostTestHarness FindBackendTest;
+
+// This test takes two WebContents objects, searches in both of them and
+// tests the internal state for find_text and find_prepopulate_text.
+TEST_F(FindBackendTest, InternalState) {
+ // Initial state for the WebContents is blank strings.
+ EXPECT_EQ(string16(), contents()->find_prepopulate_text());
+ EXPECT_EQ(string16(), contents()->find_text());
+
+ // Get another WebContents object ready.
+ WebContents* contents2 = new TestWebContents(profile_.get(), NULL);
+ NavigationController* controller2 =
+ new NavigationController(contents2, profile_.get());
+ contents2->set_controller(controller2);
+
+ // No search has still been issued, strings should be blank.
+ EXPECT_EQ(string16(), contents()->find_prepopulate_text());
+ EXPECT_EQ(string16(), contents()->find_text());
+ EXPECT_EQ(string16(), contents2->find_prepopulate_text());
+ EXPECT_EQ(string16(), contents2->find_text());
+
+ string16 search_term1 = L" I had a 401K ";
+ string16 search_term2 = L" but the economy ";
+ string16 search_term3 = L" eated it. ";
+
+ // Start searching in the first WebContents.
+ contents()->StartFinding(search_term1, true); // true=forward.
+
+ // Pre-populate string should always match between the two, but find_text
+ // should not.
+ EXPECT_EQ(search_term1, contents()->find_prepopulate_text());
+ EXPECT_EQ(search_term1, contents()->find_text());
+ EXPECT_EQ(search_term1, contents2->find_prepopulate_text());
+ EXPECT_EQ(string16(), contents2->find_text());
+
+ // Now search in the other WebContents.
+ contents2->StartFinding(search_term2, true); // true=forward.
+
+ // Again, pre-populate string should always match between the two, but
+ // find_text should not.
+ EXPECT_EQ(search_term2, contents()->find_prepopulate_text());
+ EXPECT_EQ(search_term1, contents()->find_text());
+ EXPECT_EQ(search_term2, contents2->find_prepopulate_text());
+ EXPECT_EQ(search_term2, contents2->find_text());
+
+ // Search again in the first WebContents.
+ contents()->StartFinding(search_term3, true); // true=forward.
+
+ // Once more, pre-populate string should always match between the two, but
+ // find_text should not.
+ EXPECT_EQ(search_term3, contents()->find_prepopulate_text());
+ EXPECT_EQ(search_term3, contents()->find_text());
+ EXPECT_EQ(search_term3, contents2->find_prepopulate_text());
+ EXPECT_EQ(search_term2, contents2->find_text());
+
+ contents2->CloseContents();
+}
diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj
index 4a7adb9..18f654a 100644
--- a/chrome/test/unit/unittests.vcproj
+++ b/chrome/test/unit/unittests.vcproj
@@ -520,6 +520,10 @@
>
</File>
<File
+ RelativePath="..\..\browser\find_backend_unittest.cc"
+ >
+ </File>
+ <File
RelativePath="..\..\browser\views\find_bar_win_unittest.cc"
>
</File>