Chromium Code Reviews| Index: extensions/browser/preload_check_test_util.cc |
| diff --git a/extensions/browser/preload_check_test_util.cc b/extensions/browser/preload_check_test_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2cb380436ec3d926a8d96312aa268d0c2a9fcf13 |
| --- /dev/null |
| +++ b/extensions/browser/preload_check_test_util.cc |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2017 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 "extensions/browser/preload_check_test_util.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/run_loop.h" |
| + |
| +namespace extensions { |
| + |
| +PreloadCheckObserver::PreloadCheckObserver() : called_(false) {} |
| +PreloadCheckObserver::~PreloadCheckObserver() {} |
| + |
| +void PreloadCheckObserver::OnCheckComplete(PreloadCheck::Errors errors) { |
| + CHECK(!called_); |
|
Devlin
2017/03/14 01:44:34
Can we ASSERT_FALSE here?
michaelpg
2017/03/14 21:58:30
I'd prefer not to #include gtest.h here. I'd rathe
Devlin
2017/03/16 01:42:44
Any particular reason? It's already a test-only f
michaelpg
2017/03/17 02:34:26
Meh. The crash does look uglier, so Done.
|
| + called_ = true; |
| + errors_ = errors; |
| +} |
| + |
| +void PreloadCheckObserver::Wait() { |
| + if (called_) |
| + return; |
| + |
| + base::RunLoop().RunUntilIdle(); |
|
Devlin
2017/03/14 01:44:34
This can be pretty finicky, given post task comple
michaelpg
2017/03/14 21:58:30
Can you expand on "finicky", please? I copied this
Devlin
2017/03/16 01:42:44
The finicky bits are when RunUntilIdle() doesn't a
michaelpg
2017/03/17 02:34:26
Meh again. How about using two functions, WaitForC
|
| +} |
| + |
| +} // namespace extensions |