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

Side by Side Diff: extensions/browser/preload_check_test_util.h

Issue 2783143005: Replace ExtensionInstallChecker with generic PreloadCheckGroup (Closed)
Patch Set: fix debug build Created 3 years, 8 months 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 5 #ifndef EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 6 #define EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 13 matching lines...) Expand all
24 PreloadCheckRunner(); 24 PreloadCheckRunner();
25 virtual ~PreloadCheckRunner(); 25 virtual ~PreloadCheckRunner();
26 26
27 // Starts the check, providing OnCheckComplete as the callback. 27 // Starts the check, providing OnCheckComplete as the callback.
28 void Run(PreloadCheck* check); 28 void Run(PreloadCheck* check);
29 29
30 // Starts the check and waits for its callback to execute. 30 // Starts the check and waits for its callback to execute.
31 void RunUntilComplete(PreloadCheck* check); 31 void RunUntilComplete(PreloadCheck* check);
32 32
33 // Runs the message loop until OnCheckComplete is called. 33 // Runs the message loop until OnCheckComplete is called.
34 void WaitForCompletion(); 34 void WaitForComplete();
35 35
36 // Runs the message loop until idle. Useful to see whether OnCheckComplete is 36 // Runs the message loop until idle. Useful to see whether OnCheckComplete is
37 // called without waiting indefinitely. 37 // called without waiting indefinitely.
38 void WaitForIdle(); 38 void WaitForIdle();
39 39
40 PreloadCheck::ResultCallback GetCallback(); 40 PreloadCheck::ResultCallback GetCallback();
41 41
42 const PreloadCheck::Errors& errors() const { return errors_; } 42 const PreloadCheck::Errors& errors() const { return errors_; }
43 bool called() const { return called_; } 43 bool called() const { return called_; }
44 44
45 private: 45 private:
46 void OnCheckComplete(PreloadCheck::Errors errors); 46 void OnCheckComplete(PreloadCheck::Errors errors);
47 47
48 PreloadCheck::Errors errors_; 48 PreloadCheck::Errors errors_;
49 bool called_; 49 bool called_;
50 50
51 // Using a RunLoop data member would trigger tricky timing troubles. 51 // Using a RunLoop data member would trigger tricky timing troubles.
52 std::unique_ptr<base::RunLoop> run_loop_; 52 std::unique_ptr<base::RunLoop> run_loop_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner); 54 DISALLOW_COPY_AND_ASSIGN(PreloadCheckRunner);
55 }; 55 };
56 56
57 // Stub for a PreloadCheck that returns the desired error(s). 57 // Stub for a PreloadCheck that calls the callback with the given error(s).
58 class PreloadCheckStub : public PreloadCheck { 58 class PreloadCheckStub : public PreloadCheck {
59 public: 59 public:
60 PreloadCheckStub(); 60 explicit PreloadCheckStub(const Errors& errors);
61 ~PreloadCheckStub() override; 61 ~PreloadCheckStub() override;
62 62
63 void AddError(Error error);
64 void set_error_message(const base::string16& message) { message_ = message; }
65
66 bool is_async() const { return is_async_; }
67 void set_is_async(bool is_async) { is_async_ = is_async; } 63 void set_is_async(bool is_async) { is_async_ = is_async; }
64 bool started() const { return started_; }
68 65
69 // PreloadCheck: 66 // PreloadCheck:
70 void Start(ResultCallback callback) override; 67 void Start(ResultCallback callback) override;
71 base::string16 GetErrorMessage() const override;
72 68
73 private: 69 private:
74 void RunCallback(ResultCallback callback); 70 void RunCallback(ResultCallback callback);
75 71
76 bool is_async_ = false; 72 bool is_async_ = false;
73 bool started_ = false;
77 Errors errors_; 74 Errors errors_;
78 base::string16 message_;
79 75
80 base::WeakPtrFactory<PreloadCheckStub> weak_ptr_factory_; 76 base::WeakPtrFactory<PreloadCheckStub> weak_ptr_factory_;
81 77
82 DISALLOW_COPY_AND_ASSIGN(PreloadCheckStub); 78 DISALLOW_COPY_AND_ASSIGN(PreloadCheckStub);
83 }; 79 };
84 80
85 } // namespace extensions 81 } // namespace extensions
86 82
87 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_ 83 #endif // EXTENSIONS_BROWSER_PRELOAD_CHECK_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « extensions/browser/preload_check_group_unittest.cc ('k') | extensions/browser/preload_check_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698