summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 18:54:02 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 18:54:02 +0000
commita618550847f7c09eea7bb27e43bb226f330e5525 (patch)
tree6934dcf3e855b910887aa80958990939ca59d761 /chrome/browser/history
parent2b99be2e12968b5d3d4f5818d6a76a8d42d818bc (diff)
downloadchromium_src-a618550847f7c09eea7bb27e43bb226f330e5525.zip
chromium_src-a618550847f7c09eea7bb27e43bb226f330e5525.tar.gz
chromium_src-a618550847f7c09eea7bb27e43bb226f330e5525.tar.bz2
Port some unit tests in chrome/browser/
This first requires http://codereview.chromium.org/8618 . Only snippet_unittest is enabled for build. For rest of files it's only a platform cleanup. Review URL: http://codereview.chromium.org/8191 Patch from Paweł Hajdan jr. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/query_parser_unittest.cc4
-rw-r--r--chrome/browser/history/snippet_unittest.cc6
-rw-r--r--chrome/browser/history/text_database_manager_unittest.cc30
-rw-r--r--chrome/browser/history/thumbnail_database_unittest.cc23
4 files changed, 25 insertions, 38 deletions
diff --git a/chrome/browser/history/query_parser_unittest.cc b/chrome/browser/history/query_parser_unittest.cc
index 1e0b36d..7246adc 100644
--- a/chrome/browser/history/query_parser_unittest.cc
+++ b/chrome/browser/history/query_parser_unittest.cc
@@ -76,7 +76,7 @@ TEST_F(QueryParserTest, NumWords) {
{ L"foo \"bar baz\" blah", 4 },
};
- for (int i = 0; i < arraysize(data); ++i) {
+ for (size_t i = 0; i < arraysize(data); ++i) {
std::wstring query_string;
EXPECT_EQ(data[i].expected_word_count,
query_parser_.ParseQuery(data[i].input, &query_string));
@@ -105,7 +105,7 @@ TEST_F(QueryParserTest, ParseQueryNodesAndMatch) {
{ L"\"foo blah\"", L"\"foo blah\"", true, 1, 9, 0, 0 },
{ L"foo blah", L"\"foo bar blah\"", true, 1, 4, 9, 13 },
};
- for (int i = 0; i < arraysize(data); ++i) {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
std::vector<std::wstring> results;
QueryParser parser;
ScopedVector<QueryNode> query_nodes;
diff --git a/chrome/browser/history/snippet_unittest.cc b/chrome/browser/history/snippet_unittest.cc
index b137077..3208cf4 100644
--- a/chrome/browser/history/snippet_unittest.cc
+++ b/chrome/browser/history/snippet_unittest.cc
@@ -228,7 +228,7 @@ TEST(Snippets, DISABLED_ThaiUTF8) {
TEST(Snippets, ExtractMatchPositions) {
struct TestData {
const std::string offsets_string;
- const int expected_match_count;
+ const size_t expected_match_count;
const int expected_matches[10];
} data[] = {
{ "0 0 1 2 0 0 4 1 0 0 1 5", 1, { 1,6 } },
@@ -242,11 +242,11 @@ TEST(Snippets, ExtractMatchPositions) {
{ "0 0 1 2 0 0 1 1", 1, { 1,3 } },
{ "0 0 1 1 0 0 5 2 0 0 10 1 0 0 3 10", 2, { 1,2, 3,13 } },
};
- for (int i = 0; i < arraysize(data); ++i) {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
Snippet::MatchPositions matches;
Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches);
EXPECT_EQ(data[i].expected_match_count, matches.size());
- for (int j = 0; j < data[i].expected_match_count; ++j) {
+ for (size_t j = 0; j < data[i].expected_match_count; ++j) {
EXPECT_EQ(data[i].expected_matches[2 * j], matches[j].first);
EXPECT_EQ(data[i].expected_matches[2 * j + 1], matches[j].second);
}
diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc
index b080def..8d9c10b 100644
--- a/chrome/browser/history/text_database_manager_unittest.cc
+++ b/chrome/browser/history/text_database_manager_unittest.cc
@@ -182,7 +182,7 @@ TEST_F(TextDatabaseManagerTest, InsertQuery) {
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
// We should have matched every page.
- EXPECT_EQ(6, results.size());
+ EXPECT_EQ(6U, results.size());
EXPECT_TRUE(ResultsHaveURL(results, kURL1));
EXPECT_TRUE(ResultsHaveURL(results, kURL2));
EXPECT_TRUE(ResultsHaveURL(results, kURL3));
@@ -215,7 +215,7 @@ TEST_F(TextDatabaseManagerTest, InsertCompleteNoVisit) {
Time first_time_searched;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- ASSERT_EQ(1, results.size());
+ ASSERT_EQ(1U, results.size());
EXPECT_EQ(kTitle1, results[0].title);
}
@@ -250,7 +250,7 @@ TEST_F(TextDatabaseManagerTest, InsertCompleteVisit) {
Time first_time_searched;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- ASSERT_EQ(1, results.size());
+ ASSERT_EQ(1U, results.size());
EXPECT_EQ(kTitle2, results[0].title);
// Check that the visit got updated for its new indexed state.
@@ -291,7 +291,7 @@ TEST_F(TextDatabaseManagerTest, InsertPartial) {
std::vector<TextDatabase::Match> results;
Time first_time_searched;
manager.GetTextMatches(L"google", options, &results, &first_time_searched);
- ASSERT_EQ(0, results.size());
+ ASSERT_EQ(0U, results.size());
// Compute a time threshold that will cause everything to be flushed, and
// poke at the manager's internals to cause this to happen.
@@ -300,7 +300,7 @@ TEST_F(TextDatabaseManagerTest, InsertPartial) {
// Now we should have all 3 URLs added.
manager.GetTextMatches(L"google", options, &results, &first_time_searched);
- ASSERT_EQ(3, results.size());
+ ASSERT_EQ(3U, results.size());
EXPECT_TRUE(ResultsHaveURL(results, kURL1));
EXPECT_TRUE(ResultsHaveURL(results, kURL2));
EXPECT_TRUE(ResultsHaveURL(results, kURL3));
@@ -377,7 +377,7 @@ TEST_F(TextDatabaseManagerTest, Writing) {
// We should have matched every page.
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(6, results.size());
+ EXPECT_EQ(6U, results.size());
}
results.clear();
@@ -388,7 +388,7 @@ TEST_F(TextDatabaseManagerTest, Writing) {
// We should have matched every page again.
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(6, results.size());
+ EXPECT_EQ(6U, results.size());
}
}
@@ -415,7 +415,7 @@ TEST_F(TextDatabaseManagerTest, WritingTransaction) {
// We should have matched every page.
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(6, results.size());
+ EXPECT_EQ(6U, results.size());
}
results.clear();
@@ -426,7 +426,7 @@ TEST_F(TextDatabaseManagerTest, WritingTransaction) {
// We should have matched every page again.
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(6, results.size());
+ EXPECT_EQ(6U, results.size());
}
}
@@ -450,7 +450,7 @@ TEST_F(TextDatabaseManagerTest, QueryMax) {
// We should have gotten the last two pages as results (the first page is
// also the last).
- EXPECT_EQ(2, results.size());
+ EXPECT_EQ(2U, results.size());
EXPECT_TRUE(first_time_searched <= times[4]);
EXPECT_TRUE(ResultsHaveURL(results, kURL5));
EXPECT_TRUE(ResultsHaveURL(results, kURL1));
@@ -459,7 +459,7 @@ TEST_F(TextDatabaseManagerTest, QueryMax) {
options.max_count = 4;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(4, results.size());
+ EXPECT_EQ(4U, results.size());
EXPECT_TRUE(first_time_searched <= times[4]);
EXPECT_TRUE(ResultsHaveURL(results, kURL3));
EXPECT_TRUE(ResultsHaveURL(results, kURL4));
@@ -489,7 +489,7 @@ TEST_F(TextDatabaseManagerTest, QueryBackwards) {
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
// Check that we got the last two results.
- EXPECT_EQ(2, results.size());
+ EXPECT_EQ(2U, results.size());
EXPECT_TRUE(first_time_searched <= times[4]);
EXPECT_TRUE(ResultsHaveURL(results, kURL5));
EXPECT_TRUE(ResultsHaveURL(results, kURL1));
@@ -497,7 +497,7 @@ TEST_F(TextDatabaseManagerTest, QueryBackwards) {
// Query the previous two URLs and make sure we got the correct ones.
options.end_time = first_time_searched;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(2, results.size());
+ EXPECT_EQ(2U, results.size());
EXPECT_TRUE(first_time_searched <= times[2]);
EXPECT_TRUE(ResultsHaveURL(results, kURL3));
EXPECT_TRUE(ResultsHaveURL(results, kURL4));
@@ -505,7 +505,7 @@ TEST_F(TextDatabaseManagerTest, QueryBackwards) {
// Query the previous two URLs...
options.end_time = first_time_searched;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(2, results.size());
+ EXPECT_EQ(2U, results.size());
EXPECT_TRUE(first_time_searched <= times[0]);
EXPECT_TRUE(ResultsHaveURL(results, kURL2));
EXPECT_TRUE(ResultsHaveURL(results, kURL1));
@@ -513,7 +513,7 @@ TEST_F(TextDatabaseManagerTest, QueryBackwards) {
// Try to query some more, there should be no results.
options.end_time = first_time_searched;
manager.GetTextMatches(L"FOO", options, &results, &first_time_searched);
- EXPECT_EQ(0, results.size());
+ EXPECT_EQ(0U, results.size());
}
} // namespace history
diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc
index 7507536..c8ad456 100644
--- a/chrome/browser/history/thumbnail_database_unittest.cc
+++ b/chrome/browser/history/thumbnail_database_unittest.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-
#include "base/basictypes.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -35,16 +33,15 @@ class ThumbnailDatabaseTest : public testing::Test {
virtual void SetUp() {
// get an empty file for the test DB
PathService::Get(chrome::DIR_TEST_DATA, &file_name_);
- file_name_.push_back(file_util::kPathSeparator);
- file_name_.append(L"TestThumbnails.db");
- DeleteFile(file_name_.c_str());
+ file_util::AppendToPath(&file_name_, L"TestThumbnails.db");
+ file_util::Delete(file_name_, false);
google_bitmap_.reset(
JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail)));
}
virtual void TearDown() {
- DeleteFile(file_name_.c_str());
+ file_util::Delete(file_name_, false);
}
scoped_ptr<SkBitmap> google_bitmap_;
@@ -64,17 +61,7 @@ const double kWorseBoringness = 0.50;
const double kBetterBoringness = 0.10;
const double kTotallyBoring = 1.0;
-const __int64 kPage1 = 1234;
-
-// converts out constant data above to a vector for SetPageThumbnail
-static std::vector<unsigned char> StringToVector(const unsigned char* str) {
- size_t len = strlen(reinterpret_cast<const char*>(str));
- std::vector<unsigned char> vect;
- vect.resize(len);
-
- memcpy(&vect[0], str, len);
- return vect;
-}
+const int64 kPage1 = 1234;
} // namespace
@@ -93,7 +80,7 @@ TEST_F(ThumbnailDatabaseTest, AddDelete) {
ASSERT_TRUE(boring.Equals(score_output));
// Verify a random page is not found.
- __int64 page2 = 5678;
+ int64 page2 = 5678;
std::vector<unsigned char> jpeg_data;
EXPECT_FALSE(db.GetPageThumbnail(page2, &jpeg_data));
EXPECT_FALSE(db.ThumbnailScoreForId(page2, &score_output));