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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc

Issue 624153002: replace OVERRIDE and FINAL with override and 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 (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file.h" 6 #include "base/files/file.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 write_flags |= base::File::FLAG_ASYNC; 74 write_flags |= base::File::FLAG_ASYNC;
75 #endif 75 #endif
76 76
77 return scoped_ptr<NativeProcessLauncher>(new FakeLauncher( 77 return scoped_ptr<NativeProcessLauncher>(new FakeLauncher(
78 read_pipe.Pass(), 78 read_pipe.Pass(),
79 base::File(write_file, write_flags))); 79 base::File(write_file, write_flags)));
80 } 80 }
81 81
82 virtual void Launch(const GURL& origin, 82 virtual void Launch(const GURL& origin,
83 const std::string& native_host_name, 83 const std::string& native_host_name,
84 LaunchedCallback callback) const OVERRIDE { 84 LaunchedCallback callback) const override {
85 callback.Run(NativeProcessLauncher::RESULT_SUCCESS, 85 callback.Run(NativeProcessLauncher::RESULT_SUCCESS,
86 base::kNullProcessHandle, 86 base::kNullProcessHandle,
87 read_file_.Pass(), write_file_.Pass()); 87 read_file_.Pass(), write_file_.Pass());
88 } 88 }
89 89
90 private: 90 private:
91 mutable base::File read_file_; 91 mutable base::File read_file_;
92 mutable base::File write_file_; 92 mutable base::File write_file_;
93 }; 93 };
94 94
95 class NativeMessagingTest : public ::testing::Test, 95 class NativeMessagingTest : public ::testing::Test,
96 public NativeMessageProcessHost::Client, 96 public NativeMessageProcessHost::Client,
97 public base::SupportsWeakPtr<NativeMessagingTest> { 97 public base::SupportsWeakPtr<NativeMessagingTest> {
98 protected: 98 protected:
99 NativeMessagingTest() 99 NativeMessagingTest()
100 : current_channel_(chrome::VersionInfo::CHANNEL_DEV), 100 : current_channel_(chrome::VersionInfo::CHANNEL_DEV),
101 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 101 thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
102 channel_closed_(false) {} 102 channel_closed_(false) {}
103 103
104 virtual void SetUp() OVERRIDE { 104 virtual void SetUp() override {
105 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 105 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
106 } 106 }
107 107
108 virtual void TearDown() OVERRIDE { 108 virtual void TearDown() override {
109 if (native_message_process_host_.get()) { 109 if (native_message_process_host_.get()) {
110 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, 110 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
111 native_message_process_host_.release()); 111 native_message_process_host_.release());
112 } 112 }
113 base::RunLoop().RunUntilIdle(); 113 base::RunLoop().RunUntilIdle();
114 } 114 }
115 115
116 virtual void PostMessageFromNativeProcess( 116 virtual void PostMessageFromNativeProcess(
117 int port_id, 117 int port_id,
118 const std::string& message) OVERRIDE { 118 const std::string& message) override {
119 last_message_ = message; 119 last_message_ = message;
120 120
121 // Parse the message. 121 // Parse the message.
122 base::Value* parsed = base::JSONReader::Read(message); 122 base::Value* parsed = base::JSONReader::Read(message);
123 base::DictionaryValue* dict_value; 123 base::DictionaryValue* dict_value;
124 if (parsed && parsed->GetAsDictionary(&dict_value)) { 124 if (parsed && parsed->GetAsDictionary(&dict_value)) {
125 last_message_parsed_.reset(dict_value); 125 last_message_parsed_.reset(dict_value);
126 } else { 126 } else {
127 LOG(ERROR) << "Failed to parse " << message; 127 LOG(ERROR) << "Failed to parse " << message;
128 last_message_parsed_.reset(); 128 last_message_parsed_.reset();
129 delete parsed; 129 delete parsed;
130 } 130 }
131 131
132 if (run_loop_) 132 if (run_loop_)
133 run_loop_->Quit(); 133 run_loop_->Quit();
134 } 134 }
135 135
136 virtual void CloseChannel(int port_id, 136 virtual void CloseChannel(int port_id,
137 const std::string& error_message) OVERRIDE { 137 const std::string& error_message) override {
138 channel_closed_ = true; 138 channel_closed_ = true;
139 if (run_loop_) 139 if (run_loop_)
140 run_loop_->Quit(); 140 run_loop_->Quit();
141 } 141 }
142 142
143 protected: 143 protected:
144 std::string FormatMessage(const std::string& message) { 144 std::string FormatMessage(const std::string& message) {
145 uint32_t length = message.length(); 145 uint32_t length = message.length();
146 return std::string(reinterpret_cast<char*>(&length), 4).append(message); 146 return std::string(reinterpret_cast<char*>(&length), 4).append(message);
147 } 147 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 ScopedTestNativeMessagingHost::kHostName, 0, false); 312 ScopedTestNativeMessagingHost::kHostName, 0, false);
313 ASSERT_TRUE(native_message_process_host_.get()); 313 ASSERT_TRUE(native_message_process_host_.get());
314 run_loop_.reset(new base::RunLoop()); 314 run_loop_.reset(new base::RunLoop());
315 run_loop_->Run(); 315 run_loop_->Run();
316 316
317 // The host should fail to start. 317 // The host should fail to start.
318 ASSERT_TRUE(channel_closed_); 318 ASSERT_TRUE(channel_closed_);
319 } 319 }
320 320
321 } // namespace extensions 321 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698