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

Side by Side Diff: chrome/browser/extensions/activity_log/ad_injection_browsertest.cc

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 #include "base/files/file_path.h" 5 #include "base/files/file_path.h"
6 #include "base/scoped_observer.h" 6 #include "base/scoped_observer.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/extensions/activity_log/activity_actions.h" 10 #include "chrome/browser/extensions/activity_log/activity_actions.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 injection_type_ = Action::NO_AD_INJECTION; 86 injection_type_ = Action::NO_AD_INJECTION;
87 found_multiple_injections_ = false; 87 found_multiple_injections_ = false;
88 enabled_ = true; 88 enabled_ = true;
89 } 89 }
90 90
91 Action::InjectionType injection_type() const { return injection_type_; } 91 Action::InjectionType injection_type() const { return injection_type_; }
92 92
93 bool found_multiple_injections() const { return found_multiple_injections_; } 93 bool found_multiple_injections() const { return found_multiple_injections_; }
94 94
95 private: 95 private:
96 virtual void OnExtensionActivity(scoped_refptr<Action> action) override; 96 void OnExtensionActivity(scoped_refptr<Action> action) override;
97 97
98 ScopedObserver<ActivityLog, ActivityLog::Observer> scoped_observer_; 98 ScopedObserver<ActivityLog, ActivityLog::Observer> scoped_observer_;
99 99
100 // The associated BrowserContext. 100 // The associated BrowserContext.
101 content::BrowserContext* context_; 101 content::BrowserContext* context_;
102 102
103 // The type of the last injection. 103 // The type of the last injection.
104 Action::InjectionType injection_type_; 104 Action::InjectionType injection_type_;
105 105
106 // Whether or not we found multiple injection types (which shouldn't happen). 106 // Whether or not we found multiple injection types (which shouldn't happen).
(...skipping 25 matching lines...) Expand all
132 found_multiple_injections_ = true; 132 found_multiple_injections_ = true;
133 injection_type_ = type; 133 injection_type_ = type;
134 } 134 }
135 } 135 }
136 136
137 // A mock for the AdNetworkDatabase. This simply says that the URL 137 // A mock for the AdNetworkDatabase. This simply says that the URL
138 // http://www.known-ads.adnetwork is an ad network, and nothing else is. 138 // http://www.known-ads.adnetwork is an ad network, and nothing else is.
139 class TestAdNetworkDatabase : public AdNetworkDatabase { 139 class TestAdNetworkDatabase : public AdNetworkDatabase {
140 public: 140 public:
141 TestAdNetworkDatabase(); 141 TestAdNetworkDatabase();
142 virtual ~TestAdNetworkDatabase(); 142 ~TestAdNetworkDatabase() override;
143 143
144 private: 144 private:
145 virtual bool IsAdNetwork(const GURL& url) const override; 145 bool IsAdNetwork(const GURL& url) const override;
146 146
147 GURL ad_network_url1_; 147 GURL ad_network_url1_;
148 GURL ad_network_url2_; 148 GURL ad_network_url2_;
149 }; 149 };
150 150
151 TestAdNetworkDatabase::TestAdNetworkDatabase() : ad_network_url1_(kAdNetwork1), 151 TestAdNetworkDatabase::TestAdNetworkDatabase() : ad_network_url1_(kAdNetwork1),
152 ad_network_url2_(kAdNetwork2) { 152 ad_network_url2_(kAdNetwork2) {
153 } 153 }
154 154
155 TestAdNetworkDatabase::~TestAdNetworkDatabase() {} 155 TestAdNetworkDatabase::~TestAdNetworkDatabase() {}
(...skipping 10 matching lines...) Expand all
166 return response.Pass(); 166 return response.Pass();
167 } 167 }
168 168
169 } // namespace 169 } // namespace
170 170
171 class AdInjectionBrowserTest : public ExtensionBrowserTest { 171 class AdInjectionBrowserTest : public ExtensionBrowserTest {
172 protected: 172 protected:
173 AdInjectionBrowserTest(); 173 AdInjectionBrowserTest();
174 virtual ~AdInjectionBrowserTest(); 174 virtual ~AdInjectionBrowserTest();
175 175
176 virtual void SetUpOnMainThread() override; 176 void SetUpOnMainThread() override;
177 virtual void TearDownOnMainThread() override; 177 void TearDownOnMainThread() override;
178 178
179 // Handle the "Reset Begin" stage of the test. 179 // Handle the "Reset Begin" stage of the test.
180 testing::AssertionResult HandleResetBeginStage(); 180 testing::AssertionResult HandleResetBeginStage();
181 181
182 // Handle the "Reset End" stage of the test. 182 // Handle the "Reset End" stage of the test.
183 testing::AssertionResult HandleResetEndStage(); 183 testing::AssertionResult HandleResetEndStage();
184 184
185 // Handle the "Testing" stage of the test. 185 // Handle the "Testing" stage of the test.
186 testing::AssertionResult HandleTestingStage(const std::string& message); 186 testing::AssertionResult HandleTestingStage(const std::string& message);
187 187
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // In all cases (except for "Test Complete", in which case we already 378 // In all cases (except for "Test Complete", in which case we already
379 // break'ed), we reply with a continue message. 379 // break'ed), we reply with a continue message.
380 listener()->Reply("Continue"); 380 listener()->Reply("Continue");
381 listener()->Reset(); 381 listener()->Reset();
382 } 382 }
383 } 383 }
384 384
385 // If this test grows, we should consolidate it and AdInjectionBrowserTest. 385 // If this test grows, we should consolidate it and AdInjectionBrowserTest.
386 class ExecuteScriptAdInjectionBrowserTest : public ExtensionBrowserTest { 386 class ExecuteScriptAdInjectionBrowserTest : public ExtensionBrowserTest {
387 protected: 387 protected:
388 virtual void SetUpOnMainThread() override; 388 void SetUpOnMainThread() override;
389 virtual void TearDownOnMainThread() override; 389 void TearDownOnMainThread() override;
390 }; 390 };
391 391
392 void ExecuteScriptAdInjectionBrowserTest::SetUpOnMainThread() { 392 void ExecuteScriptAdInjectionBrowserTest::SetUpOnMainThread() {
393 ExtensionBrowserTest::SetUpOnMainThread(); 393 ExtensionBrowserTest::SetUpOnMainThread();
394 394
395 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 395 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
396 embedded_test_server()->RegisterRequestHandler(base::Bind(&HandleRequest)); 396 embedded_test_server()->RegisterRequestHandler(base::Bind(&HandleRequest));
397 397
398 // Enable the activity log for this test. 398 // Enable the activity log for this test.
399 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(true); 399 ActivityLog::GetInstance(profile())->SetWatchdogAppActiveForTesting(true);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // We should have injected an ad. 432 // We should have injected an ad.
433 EXPECT_EQ(Action::INJECTION_NEW_AD, observer.injection_type()); 433 EXPECT_EQ(Action::INJECTION_NEW_AD, observer.injection_type());
434 EXPECT_FALSE(observer.found_multiple_injections()); 434 EXPECT_FALSE(observer.found_multiple_injections());
435 } 435 }
436 436
437 // TODO(rdevlin.cronin): We test a good amount of ways of injecting ads with 437 // TODO(rdevlin.cronin): We test a good amount of ways of injecting ads with
438 // the above test, but more is better in testing. 438 // the above test, but more is better in testing.
439 // See crbug.com/357204. 439 // See crbug.com/357204.
440 440
441 } // namespace extensions 441 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698