diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 12:55:00 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 12:55:00 +0000 |
commit | 33b61bcc0c64b4d44377f86df8746b54f2bce01b (patch) | |
tree | 75ce8e196f085e3799e8c0ac48ec31b2545b8a09 /chrome/browser/browsing_data_database_helper_unittest.cc | |
parent | ded71afbd762da9b5a00fceaa1b75758d317fe2b (diff) | |
download | chromium_src-33b61bcc0c64b4d44377f86df8746b54f2bce01b.zip chromium_src-33b61bcc0c64b4d44377f86df8746b54f2bce01b.tar.gz chromium_src-33b61bcc0c64b4d44377f86df8746b54f2bce01b.tar.bz2 |
Wrappers around BrowsingDataHelpers that returned canned responses.
BUG=45230
TEST=CannedBrowsingData*HelperTest.*
Review URL: http://codereview.chromium.org/2707001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_database_helper_unittest.cc')
-rw-r--r-- | chrome/browser/browsing_data_database_helper_unittest.cc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/browsing_data_database_helper_unittest.cc b/chrome/browser/browsing_data_database_helper_unittest.cc new file mode 100644 index 0000000..5b6a8d5 --- /dev/null +++ b/chrome/browser/browsing_data_database_helper_unittest.cc @@ -0,0 +1,71 @@ +// Copyright (c) 2010 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/browsing_data_database_helper.h" + +#include "chrome/test/testing_profile.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { +class TestCompletionCallback + : public CallbackRunner<Tuple1< + const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>& > > { + public: + TestCompletionCallback() + : have_result_(false) { + } + + bool have_result() const { return have_result_; } + + const std::vector<BrowsingDataDatabaseHelper::DatabaseInfo>& result() { + return result_; + } + + virtual void RunWithParams( + const Tuple1<const std::vector< + BrowsingDataDatabaseHelper::DatabaseInfo>& >& params) { + have_result_ = true; + result_ = params.a; + } + + private: + bool have_result_; + std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result_; + + DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback); +}; +} // namespace + +TEST(CannedBrowsingDataDatabaseTest, AddDatabase) { + TestingProfile profile; + + const GURL origin1("http://host1:1/"); + const GURL origin2("http://host2:1/"); + const char origin_str1[] = "http_host1_1"; + const char origin_str2[] = "http_host2_1"; + const char db1[] = "db1"; + const char db2[] = "db2"; + const char db3[] = "db3"; + + scoped_refptr<CannedBrowsingDataDatabaseHelper> helper = + new CannedBrowsingDataDatabaseHelper(&profile); + helper->AddDatabase(origin1, db1, ""); + helper->AddDatabase(origin1, db2, ""); + helper->AddDatabase(origin2, db3, ""); + + TestCompletionCallback callback; + helper->StartFetching(&callback); + ASSERT_TRUE(callback.have_result()); + + std::vector<BrowsingDataDatabaseHelper::DatabaseInfo> result = + callback.result(); + + ASSERT_EQ(3u, result.size()); + EXPECT_STREQ(origin_str1, result[0].origin_identifier.c_str()); + EXPECT_STREQ(db1, result[0].database_name.c_str()); + EXPECT_STREQ(origin_str1, result[1].origin_identifier.c_str()); + EXPECT_STREQ(db2, result[1].database_name.c_str()); + EXPECT_STREQ(origin_str2, result[2].origin_identifier.c_str()); + EXPECT_STREQ(db3, result[2].database_name.c_str()); +} |