OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 template <class TestClass> | 17 template <class TestClass> |
18 class MojoServiceWorkerTestP : public TestClass, | 18 class MojoServiceWorkerTestP : public TestClass, |
19 public testing::WithParamInterface<bool> { | 19 public testing::WithParamInterface<bool> { |
20 protected: | 20 protected: |
21 void SetUp() override { | 21 void SetUp() override { |
22 if (!is_mojo_enabled()) { | 22 is_mojo_enabled_ = GetParam(); |
| 23 if (is_mojo_enabled()) { |
23 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 24 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
24 switches::kDisableMojoServiceWorker); | 25 switches::kMojoServiceWorker); |
25 } | 26 } |
26 TestClass::SetUp(); | 27 TestClass::SetUp(); |
27 } | 28 } |
28 | 29 |
29 bool is_mojo_enabled() const { return GetParam(); } | 30 bool is_mojo_enabled() const { return is_mojo_enabled_; } |
| 31 |
| 32 private: |
| 33 bool is_mojo_enabled_ = false; |
30 }; | 34 }; |
31 | 35 |
32 template <typename Arg> | 36 template <typename Arg> |
33 void ReceiveResult(BrowserThread::ID run_quit_thread, | 37 void ReceiveResult(BrowserThread::ID run_quit_thread, |
34 const base::Closure& quit, | 38 const base::Closure& quit, |
35 Arg* out, Arg actual) { | 39 Arg* out, Arg actual) { |
36 *out = actual; | 40 *out = actual; |
37 if (!quit.is_null()) | 41 if (!quit.is_null()) |
38 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); | 42 BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); |
39 } | 43 } |
(...skipping 10 matching lines...) Expand all Loading... |
50 const base::Closure& quit = base::Closure()) { | 54 const base::Closure& quit = base::Closure()) { |
51 BrowserThread::ID id; | 55 BrowserThread::ID id; |
52 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); | 56 bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); |
53 DCHECK(ret); | 57 DCHECK(ret); |
54 return base::Bind(&ReceiveResult<Arg>, id, quit, out); | 58 return base::Bind(&ReceiveResult<Arg>, id, quit, out); |
55 } | 59 } |
56 | 60 |
57 } // namespace content | 61 } // namespace content |
58 | 62 |
59 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ | 63 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_ |
OLD | NEW |