| Index: chrome/browser/browsing_data_local_storage_helper_browsertest.cc
|
| diff --git a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc
|
| index 8a94cbc1e33d708c79a6b8a800cbe4ba56778deb..c543a53cc9c4622ed8bb17056b823da1f84c8b20 100644
|
| --- a/chrome/browser/browsing_data_local_storage_helper_browsertest.cc
|
| +++ b/chrome/browser/browsing_data_local_storage_helper_browsertest.cc
|
| @@ -18,18 +18,57 @@
|
| #include "chrome/test/ui_test_utils.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| -static const FilePath::CharType kTestFile0[] =
|
| +namespace {
|
| +class TestCompletionCallback {
|
| + public:
|
| + TestCompletionCallback()
|
| + : have_result_(false),
|
| + waiting_for_result_(false) {
|
| + }
|
| +
|
| + const std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo>& result()
|
| + {
|
| + WaitForResult();
|
| + return result_;
|
| + }
|
| +
|
| + void callback(const std::vector<
|
| + BrowsingDataLocalStorageHelper::LocalStorageInfo>& info) {
|
| + have_result_ = true;
|
| + result_ = info;
|
| + if (waiting_for_result_)
|
| + MessageLoop::current()->Quit();
|
| + }
|
| +
|
| + private:
|
| + void WaitForResult() {
|
| + if (!have_result_) {
|
| + waiting_for_result_ = true;
|
| + MessageLoop::current()->Run();
|
| + waiting_for_result_ = false;
|
| + }
|
| + }
|
| +
|
| + bool have_result_;
|
| + bool waiting_for_result_;
|
| + std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestCompletionCallback);
|
| +};
|
| +
|
| +const FilePath::CharType kTestFile0[] =
|
| FILE_PATH_LITERAL("http_www.chromium.org_0.localstorage");
|
|
|
| -static const FilePath::CharType kTestFile1[] =
|
| +const FilePath::CharType kTestFile1[] =
|
| FILE_PATH_LITERAL("http_www.google.com_0.localstorage");
|
|
|
| -static const FilePath::CharType kTestFileInvalid[] =
|
| +const FilePath::CharType kTestFileInvalid[] =
|
| FILE_PATH_LITERAL("http_www.google.com_localstorage_0.foo");
|
|
|
| // This is only here to test that extension state is not listed by the helper.
|
| -static const FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
|
| +const FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
|
| "chrome-extension_behllobkkfkfnphdnhnkndlbkcpglgmj_0.localstorage");
|
| +} // namespace
|
|
|
|
|
| class BrowsingDataLocalStorageHelperTest : public InProcessBrowserTest {
|
| @@ -128,3 +167,51 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) {
|
| }
|
| ASSERT_EQ(3, num_files);
|
| }
|
| +
|
| +IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest,
|
| + CannedAddLocalStorage) {
|
| + const GURL origin1("http://host1:1/");
|
| + const GURL origin2("http://host2:1/");
|
| + const FilePath::CharType file1[] =
|
| + FILE_PATH_LITERAL("http_host1_1.localstorage");
|
| + const FilePath::CharType file2[] =
|
| + FILE_PATH_LITERAL("http_host2_1.localstorage");
|
| +
|
| + scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
|
| + new CannedBrowsingDataLocalStorageHelper(&testing_profile_));
|
| + helper->AddLocalStorage(origin1);
|
| + helper->AddLocalStorage(origin2);
|
| +
|
| + TestCompletionCallback callback;
|
| + helper->StartFetching(
|
| + NewCallback(&callback, &TestCompletionCallback::callback));
|
| +
|
| + std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result =
|
| + callback.result();
|
| +
|
| + ASSERT_EQ(2u, result.size());
|
| + EXPECT_EQ(FilePath(file1).value(), result[0].file_path.BaseName().value());
|
| + EXPECT_EQ(FilePath(file2).value(), result[1].file_path.BaseName().value());
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, CannedUnique) {
|
| + const GURL origin("http://host1:1/");
|
| + const FilePath::CharType file[] =
|
| + FILE_PATH_LITERAL("http_host1_1.localstorage");
|
| +
|
| + scoped_refptr<CannedBrowsingDataLocalStorageHelper> helper(
|
| + new CannedBrowsingDataLocalStorageHelper(&testing_profile_));
|
| + helper->AddLocalStorage(origin);
|
| + helper->AddLocalStorage(origin);
|
| +
|
| + TestCompletionCallback callback;
|
| + helper->StartFetching(
|
| + NewCallback(&callback, &TestCompletionCallback::callback));
|
| +
|
| + std::vector<BrowsingDataLocalStorageHelper::LocalStorageInfo> result =
|
| + callback.result();
|
| +
|
| + ASSERT_EQ(1u, result.size());
|
| + EXPECT_EQ(FilePath(file).value(), result[0].file_path.BaseName().value());
|
| +}
|
| +
|
|
|