1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/basictypes.h"
9 #include "base/bind_helpers.h"
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper_browsertest.h"
15 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "testing/gtest/include/gtest/gtest.h"
22 typedef BrowsingDataHelperCallback
<content::IndexedDBInfo
>
23 TestCompletionCallback
;
25 typedef InProcessBrowserTest BrowsingDataIndexedDBHelperTest
;
27 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest
, CannedAddIndexedDB
) {
28 const GURL
origin1("http://host1:1/");
29 const GURL
origin2("http://host2:1/");
30 const base::string16
description(ASCIIToUTF16("description"));
32 scoped_refptr
<CannedBrowsingDataIndexedDBHelper
> helper(
33 new CannedBrowsingDataIndexedDBHelper());
34 helper
->AddIndexedDB(origin1
, description
);
35 helper
->AddIndexedDB(origin2
, description
);
37 TestCompletionCallback callback
;
38 helper
->StartFetching(
39 base::Bind(&TestCompletionCallback::callback
,
40 base::Unretained(&callback
)));
42 std::list
<content::IndexedDBInfo
> result
=
45 ASSERT_EQ(2U, result
.size());
46 std::list
<content::IndexedDBInfo
>::iterator info
=
48 EXPECT_EQ(origin1
, info
->origin_
);
50 EXPECT_EQ(origin2
, info
->origin_
);
53 IN_PROC_BROWSER_TEST_F(BrowsingDataIndexedDBHelperTest
, CannedUnique
) {
54 const GURL
origin("http://host1:1/");
55 const base::string16
description(ASCIIToUTF16("description"));
57 scoped_refptr
<CannedBrowsingDataIndexedDBHelper
> helper(
58 new CannedBrowsingDataIndexedDBHelper());
59 helper
->AddIndexedDB(origin
, description
);
60 helper
->AddIndexedDB(origin
, description
);
62 TestCompletionCallback callback
;
63 helper
->StartFetching(
64 base::Bind(&TestCompletionCallback::callback
,
65 base::Unretained(&callback
)));
67 std::list
<content::IndexedDBInfo
> result
=
70 ASSERT_EQ(1U, result
.size());
71 EXPECT_EQ(origin
, result
.begin()->origin_
);