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

Side by Side Diff: chrome/browser/external_protocol/external_protocol_handler_unittest.cc

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (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 (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 "chrome/browser/external_protocol/external_protocol_handler.h" 5 #include "chrome/browser/external_protocol/external_protocol_handler.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "content/public/test/test_browser_thread.h" 8 #include "content/public/test/test_browser_thread.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using content::BrowserThread; 11 using content::BrowserThread;
12 12
13 class FakeExternalProtocolHandlerWorker 13 class FakeExternalProtocolHandlerWorker
14 : public ShellIntegration::DefaultProtocolClientWorker { 14 : public ShellIntegration::DefaultProtocolClientWorker {
15 public: 15 public:
16 FakeExternalProtocolHandlerWorker( 16 FakeExternalProtocolHandlerWorker(
17 ShellIntegration::DefaultWebClientObserver* observer, 17 ShellIntegration::DefaultWebClientObserver* observer,
18 const std::string& protocol, 18 const std::string& protocol,
19 ShellIntegration::DefaultWebClientState os_state) 19 ShellIntegration::DefaultWebClientState os_state)
20 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), 20 : ShellIntegration::DefaultProtocolClientWorker(observer, protocol),
21 os_state_(os_state) {} 21 os_state_(os_state) {}
22 22
23 private: 23 private:
24 virtual ~FakeExternalProtocolHandlerWorker() {} 24 ~FakeExternalProtocolHandlerWorker() override {}
25 25
26 virtual ShellIntegration::DefaultWebClientState CheckIsDefault() override { 26 ShellIntegration::DefaultWebClientState CheckIsDefault() override {
27 return os_state_; 27 return os_state_;
28 } 28 }
29 29
30 virtual bool SetAsDefault(bool interactive_permitted) override { 30 bool SetAsDefault(bool interactive_permitted) override { return true; }
31 return true;
32 }
33 31
34 ShellIntegration::DefaultWebClientState os_state_; 32 ShellIntegration::DefaultWebClientState os_state_;
35 }; 33 };
36 34
37 class FakeExternalProtocolHandlerDelegate 35 class FakeExternalProtocolHandlerDelegate
38 : public ExternalProtocolHandler::Delegate { 36 : public ExternalProtocolHandler::Delegate {
39 public: 37 public:
40 FakeExternalProtocolHandlerDelegate() 38 FakeExternalProtocolHandlerDelegate()
41 : block_state_(ExternalProtocolHandler::BLOCK), 39 : block_state_(ExternalProtocolHandler::BLOCK),
42 os_state_(ShellIntegration::UNKNOWN_DEFAULT), 40 os_state_(ShellIntegration::UNKNOWN_DEFAULT),
43 has_launched_(false), 41 has_launched_(false),
44 has_prompted_(false), 42 has_prompted_(false),
45 has_blocked_ (false) {} 43 has_blocked_ (false) {}
46 44
47 virtual ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker( 45 ShellIntegration::DefaultProtocolClientWorker* CreateShellWorker(
48 ShellIntegration::DefaultWebClientObserver* observer, 46 ShellIntegration::DefaultWebClientObserver* observer,
49 const std::string& protocol) override { 47 const std::string& protocol) override {
50 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_); 48 return new FakeExternalProtocolHandlerWorker(observer, protocol, os_state_);
51 } 49 }
52 50
53 virtual ExternalProtocolHandler::BlockState GetBlockState( 51 ExternalProtocolHandler::BlockState GetBlockState(
54 const std::string& scheme) override { 52 const std::string& scheme) override {
55 return block_state_; 53 return block_state_;
56 } 54 }
57 55
58 virtual void BlockRequest() override { 56 void BlockRequest() override {
59 ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK || 57 ASSERT_TRUE(block_state_ == ExternalProtocolHandler::BLOCK ||
60 os_state_ == ShellIntegration::IS_DEFAULT); 58 os_state_ == ShellIntegration::IS_DEFAULT);
61 has_blocked_ = true; 59 has_blocked_ = true;
62 } 60 }
63 61
64 virtual void RunExternalProtocolDialog(const GURL& url, 62 void RunExternalProtocolDialog(const GURL& url,
65 int render_process_host_id, 63 int render_process_host_id,
66 int routing_id) override { 64 int routing_id) override {
67 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN); 65 ASSERT_EQ(block_state_, ExternalProtocolHandler::UNKNOWN);
68 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); 66 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT);
69 has_prompted_ = true; 67 has_prompted_ = true;
70 } 68 }
71 69
72 virtual void LaunchUrlWithoutSecurityCheck(const GURL& url) override { 70 void LaunchUrlWithoutSecurityCheck(const GURL& url) override {
73 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK); 71 ASSERT_EQ(block_state_, ExternalProtocolHandler::DONT_BLOCK);
74 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT); 72 ASSERT_NE(os_state_, ShellIntegration::IS_DEFAULT);
75 has_launched_ = true; 73 has_launched_ = true;
76 } 74 }
77 75
78 virtual void FinishedProcessingCheck() override { 76 void FinishedProcessingCheck() override {
79 base::MessageLoop::current()->Quit(); 77 base::MessageLoop::current()->Quit();
80 } 78 }
81 79
82 void set_os_state(ShellIntegration::DefaultWebClientState value) { 80 void set_os_state(ShellIntegration::DefaultWebClientState value) {
83 os_state_ = value; 81 os_state_ = value;
84 } 82 }
85 83
86 void set_block_state(ExternalProtocolHandler::BlockState value) { 84 void set_block_state(ExternalProtocolHandler::BlockState value) {
87 block_state_ = value; 85 block_state_ = value;
88 } 86 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 DoTest(ExternalProtocolHandler::UNKNOWN, 184 DoTest(ExternalProtocolHandler::UNKNOWN,
187 ShellIntegration::NOT_DEFAULT, 185 ShellIntegration::NOT_DEFAULT,
188 true, false, false); 186 true, false, false);
189 } 187 }
190 188
191 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) { 189 TEST_F(ExternalProtocolHandlerTest, TestLaunchSchemeUnknownChromeUnknown) {
192 DoTest(ExternalProtocolHandler::UNKNOWN, 190 DoTest(ExternalProtocolHandler::UNKNOWN,
193 ShellIntegration::UNKNOWN_DEFAULT, 191 ShellIntegration::UNKNOWN_DEFAULT,
194 true, false, false); 192 true, false, false);
195 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698