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

Side by Side Diff: components/rlz/rlz_tracker_unittest.cc

Issue 1496493004: Revert of Tests: Simplify SequencedWorkerPoolOwner, call Shutdown on destructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "components/rlz/rlz_tracker.h" 5 #include "components/rlz/rlz_tracker.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/sequenced_worker_pool_owner.h"
12 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "base/threading/sequenced_worker_pool.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/rlz/rlz_tracker_delegate.h" 14 #include "components/rlz/rlz_tracker_delegate.h"
15 #include "net/url_request/url_request_test_util.h" 15 #include "net/url_request/url_request_test_util.h"
16 #include "rlz/test/rlz_test_helpers.h" 16 #include "rlz/test/rlz_test_helpers.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 #if defined(OS_IOS) 19 #if defined(OS_IOS)
20 #include "ui/base/device_form_factor.h" 20 #include "ui/base/device_form_factor.h"
21 #endif 21 #endif
22 22
23 using testing::AssertionResult; 23 using testing::AssertionResult;
24 using testing::AssertionSuccess; 24 using testing::AssertionSuccess;
25 using testing::AssertionFailure; 25 using testing::AssertionFailure;
26 26
27 namespace rlz { 27 namespace rlz {
28 namespace { 28 namespace {
29 29
30 class TestRLZTrackerDelegate : public RLZTrackerDelegate { 30 class TestRLZTrackerDelegate : public RLZTrackerDelegate {
31 public: 31 public:
32 TestRLZTrackerDelegate() 32 TestRLZTrackerDelegate()
33 : worker_pool_owner_(1, "TestRLZTracker"), 33 : worker_pool_(new base::SequencedWorkerPool(1, "TestRLZTracker")),
34 request_context_getter_(new net::TestURLRequestContextGetter( 34 request_context_getter_(new net::TestURLRequestContextGetter(
35 base::ThreadTaskRunnerHandle::Get())) {} 35 base::ThreadTaskRunnerHandle::Get())) {}
36 36
37 ~TestRLZTrackerDelegate() override { worker_pool_->Shutdown(); }
38
37 void set_brand(const char* brand) { brand_override_ = brand; } 39 void set_brand(const char* brand) { brand_override_ = brand; }
38 40
39 void set_reactivation_brand(const char* reactivation_brand) { 41 void set_reactivation_brand(const char* reactivation_brand) {
40 // TODO(thakis): Reactivation doesn't exist on Mac yet. 42 // TODO(thakis): Reactivation doesn't exist on Mac yet.
41 reactivation_brand_override_ = reactivation_brand; 43 reactivation_brand_override_ = reactivation_brand;
42 } 44 }
43 45
44 void SimulateOmniboxUsage() { 46 void SimulateOmniboxUsage() {
45 using std::swap; 47 using std::swap;
46 base::Closure callback; 48 base::Closure callback;
(...skipping 12 matching lines...) Expand all
59 61
60 // RLZTrackerDelegate implementation. 62 // RLZTrackerDelegate implementation.
61 void Cleanup() override { 63 void Cleanup() override {
62 on_omnibox_search_callback_.Reset(); 64 on_omnibox_search_callback_.Reset();
63 on_homepage_search_callback_.Reset(); 65 on_homepage_search_callback_.Reset();
64 } 66 }
65 67
66 bool IsOnUIThread() override { return true; } 68 bool IsOnUIThread() override { return true; }
67 69
68 base::SequencedWorkerPool* GetBlockingPool() override { 70 base::SequencedWorkerPool* GetBlockingPool() override {
69 return worker_pool_owner_.pool().get(); 71 return worker_pool_.get();
70 } 72 }
71 73
72 net::URLRequestContextGetter* GetRequestContext() override { 74 net::URLRequestContextGetter* GetRequestContext() override {
73 return request_context_getter_.get(); 75 return request_context_getter_.get();
74 } 76 }
75 77
76 bool GetBrand(std::string* brand) override { 78 bool GetBrand(std::string* brand) override {
77 *brand = brand_override_; 79 *brand = brand_override_;
78 return true; 80 return true;
79 } 81 }
(...skipping 19 matching lines...) Expand all
99 DCHECK(!callback.is_null()); 101 DCHECK(!callback.is_null());
100 on_omnibox_search_callback_ = callback; 102 on_omnibox_search_callback_ = callback;
101 } 103 }
102 104
103 void SetHomepageSearchCallback(const base::Closure& callback) override { 105 void SetHomepageSearchCallback(const base::Closure& callback) override {
104 DCHECK(!callback.is_null()); 106 DCHECK(!callback.is_null());
105 on_homepage_search_callback_ = callback; 107 on_homepage_search_callback_ = callback;
106 } 108 }
107 109
108 private: 110 private:
109 base::SequencedWorkerPoolOwner worker_pool_owner_; 111 scoped_refptr<base::SequencedWorkerPool> worker_pool_;
110 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 112 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
111 113
112 std::string brand_override_; 114 std::string brand_override_;
113 std::string reactivation_brand_override_; 115 std::string reactivation_brand_override_;
114 base::Closure on_omnibox_search_callback_; 116 base::Closure on_omnibox_search_callback_;
115 base::Closure on_homepage_search_callback_; 117 base::Closure on_homepage_search_callback_;
116 118
117 DISALLOW_COPY_AND_ASSIGN(TestRLZTrackerDelegate); 119 DISALLOW_COPY_AND_ASSIGN(TestRLZTrackerDelegate);
118 }; 120 };
119 121
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 1000
999 ExpectEventRecorded(OmniboxFirstSearch(), true); 1001 ExpectEventRecorded(OmniboxFirstSearch(), true);
1000 1002
1001 RLZTracker::ClearRlzState(); 1003 RLZTracker::ClearRlzState();
1002 1004
1003 ExpectEventRecorded(OmniboxFirstSearch(), false); 1005 ExpectEventRecorded(OmniboxFirstSearch(), false);
1004 } 1006 }
1005 #endif // defined(OS_CHROMEOS) 1007 #endif // defined(OS_CHROMEOS)
1006 1008
1007 } // namespace rlz 1009 } // namespace rlz
OLDNEW
« no previous file with comments | « components/component_updater/component_updater_service_unittest.cc ('k') | components/update_client/update_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698