Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: chrome/browser/extensions/test_blacklist.h

Issue 119963004: Manage all the testing classes for Blacklist in TestBlacklist. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_ 6 #define CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "chrome/browser/extensions/blacklist.h" 11 #include "chrome/browser/extensions/blacklist.h"
12 #include "chrome/browser/extensions/blacklist_state_fetcher.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
16 class FakeSafeBrowsingDatabaseManager;
17
18 class BlacklistStateFetcherMock : public BlacklistStateFetcher {
not at google - send to devlin 2013/12/21 00:34:24 class needs comment(s)
Oleg Eterevsky 2014/01/09 13:54:01 Done.
19 public:
20 BlacklistStateFetcherMock();
21
22 virtual void Request(const std::string& id,
23 const RequestCallback& callback) OVERRIDE;
24
25 void SetState(const std::string& id, BlacklistState state);
26
27 void Clear();
28
29 int request_count() const { return request_count_; }
30
31 private:
32 std::map<std::string, BlacklistState> states_;
33 int request_count_;
34 };
35
36
15 // A wrapper for an extensions::Blacklist that provides functionality for 37 // A wrapper for an extensions::Blacklist that provides functionality for
16 // testing. 38 // testing. It setts up mocks for SB database and BlacklistFetcher, that are
not at google - send to devlin 2013/12/21 00:34:24 sets
Oleg Eterevsky 2014/01/09 13:54:01 Done.
39 // used by blacklist to
not at google - send to devlin 2013/12/21 00:34:24 to..?
Oleg Eterevsky 2014/01/09 13:54:01 Done.
17 class TestBlacklist { 40 class TestBlacklist {
18 public: 41 public:
42 // Use this if the SafeBrowsing and/or StateFetcher mocks should be created
43 // before initializing the Blacklist.
44 explicit TestBlacklist();
45
19 explicit TestBlacklist(Blacklist* blacklist); 46 explicit TestBlacklist(Blacklist* blacklist);
20 47
48 ~TestBlacklist();
49
50 void Attach(Blacklist* blacklist);
51
52 // Only call this if Blacklist is destroyed before TestBlacklist, otherwise
53 // it will be performed from the destructor.
54 void Detach();
55
21 Blacklist* blacklist() { return blacklist_; } 56 Blacklist* blacklist() { return blacklist_; }
22 57
58 // Set the extension state in SafeBrowsingDatabaseManager and
59 // BlacklistFetcher.
60 void SetBlacklistState(const std::string& extension_id,
61 BlacklistState state,
62 bool notify);
63
23 BlacklistState GetBlacklistState(const std::string& extension_id); 64 BlacklistState GetBlacklistState(const std::string& extension_id);
24 65
66 void Clear(bool notify);
67
68 void DisableSafeBrowsing();
69
70 void EnableSafeBrowsing();
71
72 void NotifyUpdate();
73
74 const BlacklistStateFetcherMock* fetcher() { return &state_fetcher_mock_; }
75
25 private: 76 private:
26 Blacklist* blacklist_; 77 Blacklist* blacklist_;
27 78
79 BlacklistStateFetcherMock state_fetcher_mock_;
80
81 scoped_refptr<FakeSafeBrowsingDatabaseManager> blacklist_db_;
82
83 Blacklist::ScopedDatabaseManagerForTest scoped_blacklist_db_;
84
28 DISALLOW_COPY_AND_ASSIGN(TestBlacklist); 85 DISALLOW_COPY_AND_ASSIGN(TestBlacklist);
29 }; 86 };
30 87
31 } // namespace extensions 88 } // namespace extensions
32 89
33 #endif // CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_ 90 #endif // CHROME_BROWSER_EXTENSIONS_TEST_BLACKLIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698