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

Side by Side Diff: remoting/host/setup/me2me_native_messaging_host_unittest.cc

Issue 103053006: Renaming NativeMessagingHost to Me2MeNativeMessagingHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegage
Patch Set: Resolving merge conflict. Created 7 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
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host_main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "remoting/host/setup/me2me_native_messaging_host.h" 5 #include "remoting/host/setup/me2me_native_messaging_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 void MockDaemonControllerDelegate::Stop( 194 void MockDaemonControllerDelegate::Stop(
195 const DaemonController::CompletionCallback& done) { 195 const DaemonController::CompletionCallback& done) {
196 done.Run(DaemonController::RESULT_OK); 196 done.Run(DaemonController::RESULT_OK);
197 } 197 }
198 198
199 void MockDaemonControllerDelegate::SetWindow(void* window_handle) {} 199 void MockDaemonControllerDelegate::SetWindow(void* window_handle) {}
200 200
201 std::string MockDaemonControllerDelegate::GetVersion() { 201 std::string MockDaemonControllerDelegate::GetVersion() {
202 // Unused - NativeMessagingHost returns the compiled-in version string 202 // Unused - Me2MeNativeMessagingHost returns the compiled-in version string
203 // instead of calling this method. 203 // instead of calling this method.
204 NOTREACHED(); 204 NOTREACHED();
205 return std::string(); 205 return std::string();
206 } 206 }
207 207
208 DaemonController::UsageStatsConsent 208 DaemonController::UsageStatsConsent
209 MockDaemonControllerDelegate::GetUsageStatsConsent() { 209 MockDaemonControllerDelegate::GetUsageStatsConsent() {
210 DaemonController::UsageStatsConsent consent; 210 DaemonController::UsageStatsConsent consent;
211 consent.supported = true; 211 consent.supported = true;
212 consent.allowed = true; 212 consent.allowed = true;
213 consent.set_by_policy = true; 213 consent.set_by_policy = true;
214 return consent; 214 return consent;
215 } 215 }
216 216
217 class NativeMessagingHostTest : public testing::Test { 217 class Me2MeNativeMessagingHostTest : public testing::Test {
218 public: 218 public:
219 NativeMessagingHostTest(); 219 Me2MeNativeMessagingHostTest();
220 virtual ~NativeMessagingHostTest(); 220 virtual ~Me2MeNativeMessagingHostTest();
221 221
222 virtual void SetUp() OVERRIDE; 222 virtual void SetUp() OVERRIDE;
223 virtual void TearDown() OVERRIDE; 223 virtual void TearDown() OVERRIDE;
224 224
225 scoped_ptr<base::DictionaryValue> ReadMessageFromOutputPipe(); 225 scoped_ptr<base::DictionaryValue> ReadMessageFromOutputPipe();
226 226
227 void WriteMessageToInputPipe(const base::Value& message); 227 void WriteMessageToInputPipe(const base::Value& message);
228 228
229 // The Host process should shut down when it receives a malformed request. 229 // The Host process should shut down when it receives a malformed request.
230 // This is tested by sending a known-good request, followed by |message|, 230 // This is tested by sending a known-good request, followed by |message|,
231 // followed by the known-good request again. The response file should only 231 // followed by the known-good request again. The response file should only
232 // contain a single response from the first good request. 232 // contain a single response from the first good request.
233 void TestBadRequest(const base::Value& message); 233 void TestBadRequest(const base::Value& message);
234 234
235 protected: 235 protected:
236 // Reference to the MockDaemonControllerDelegate, which is owned by 236 // Reference to the MockDaemonControllerDelegate, which is owned by
237 // |channel_|. 237 // |channel_|.
238 MockDaemonControllerDelegate* daemon_controller_delegate_; 238 MockDaemonControllerDelegate* daemon_controller_delegate_;
239 239
240 private: 240 private:
241 void StartHost(); 241 void StartHost();
242 void StopHost(); 242 void StopHost();
243 void ExitTest(); 243 void ExitTest();
244 244
245 // Each test creates two unidirectional pipes: "input" and "output". 245 // Each test creates two unidirectional pipes: "input" and "output".
246 // NativeMessagingHost reads from input_read_handle and writes to 246 // Me2MeNativeMessagingHost reads from input_read_handle and writes to
247 // output_write_handle. The unittest supplies data to input_write_handle, and 247 // output_write_handle. The unittest supplies data to input_write_handle, and
248 // verifies output from output_read_handle. 248 // verifies output from output_read_handle.
249 // 249 //
250 // unittest -> [input] -> NativeMessagingHost -> [output] -> unittest 250 // unittest -> [input] -> Me2MeNativeMessagingHost -> [output] -> unittest
251 base::PlatformFile input_write_handle_; 251 base::PlatformFile input_write_handle_;
252 base::PlatformFile output_read_handle_; 252 base::PlatformFile output_read_handle_;
253 253
254 // Message loop of the test thread. 254 // Message loop of the test thread.
255 scoped_ptr<base::MessageLoop> test_message_loop_; 255 scoped_ptr<base::MessageLoop> test_message_loop_;
256 scoped_ptr<base::RunLoop> test_run_loop_; 256 scoped_ptr<base::RunLoop> test_run_loop_;
257 257
258 scoped_ptr<base::Thread> host_thread_; 258 scoped_ptr<base::Thread> host_thread_;
259 scoped_ptr<base::RunLoop> host_run_loop_; 259 scoped_ptr<base::RunLoop> host_run_loop_;
260 260
261 // Task runner of the host thread. 261 // Task runner of the host thread.
262 scoped_refptr<AutoThreadTaskRunner> host_task_runner_; 262 scoped_refptr<AutoThreadTaskRunner> host_task_runner_;
263 scoped_ptr<remoting::NativeMessagingHost> host_; 263 scoped_ptr<remoting::Me2MeNativeMessagingHost> host_;
264 264
265 DISALLOW_COPY_AND_ASSIGN(NativeMessagingHostTest); 265 DISALLOW_COPY_AND_ASSIGN(Me2MeNativeMessagingHostTest);
266 }; 266 };
267 267
268 NativeMessagingHostTest::NativeMessagingHostTest() {} 268 Me2MeNativeMessagingHostTest::Me2MeNativeMessagingHostTest() {}
269 269
270 NativeMessagingHostTest::~NativeMessagingHostTest() {} 270 Me2MeNativeMessagingHostTest::~Me2MeNativeMessagingHostTest() {}
271 271
272 void NativeMessagingHostTest::SetUp() { 272 void Me2MeNativeMessagingHostTest::SetUp() {
273 base::PlatformFile input_read_handle; 273 base::PlatformFile input_read_handle;
274 base::PlatformFile output_write_handle; 274 base::PlatformFile output_write_handle;
275 275
276 ASSERT_TRUE(MakePipe(&input_read_handle, &input_write_handle_)); 276 ASSERT_TRUE(MakePipe(&input_read_handle, &input_write_handle_));
277 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle)); 277 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle));
278 278
279 test_message_loop_.reset(new base::MessageLoop()); 279 test_message_loop_.reset(new base::MessageLoop());
280 test_run_loop_.reset(new base::RunLoop()); 280 test_run_loop_.reset(new base::RunLoop());
281 281
282 // Run the host on a dedicated thread. 282 // Run the host on a dedicated thread.
283 host_thread_.reset(new base::Thread("host_thread")); 283 host_thread_.reset(new base::Thread("host_thread"));
284 host_thread_->Start(); 284 host_thread_->Start();
285 285
286 // Arrange to run |test_message_loop_| until no components depend on it. 286 // Arrange to run |test_message_loop_| until no components depend on it.
287 host_task_runner_ = new AutoThreadTaskRunner( 287 host_task_runner_ = new AutoThreadTaskRunner(
288 host_thread_->message_loop_proxy(), 288 host_thread_->message_loop_proxy(),
289 base::Bind(&NativeMessagingHostTest::ExitTest, 289 base::Bind(&Me2MeNativeMessagingHostTest::ExitTest,
290 base::Unretained(this))); 290 base::Unretained(this)));
291 291
292 host_task_runner_->PostTask( 292 host_task_runner_->PostTask(
293 FROM_HERE, 293 FROM_HERE,
294 base::Bind(&NativeMessagingHostTest::StartHost, base::Unretained(this))); 294 base::Bind(&Me2MeNativeMessagingHostTest::StartHost,
295 base::Unretained(this)));
295 296
296 // Wait until the host finishes starting. 297 // Wait until the host finishes starting.
297 test_run_loop_->Run(); 298 test_run_loop_->Run();
298 } 299 }
299 300
300 void NativeMessagingHostTest::StartHost() { 301 void Me2MeNativeMessagingHostTest::StartHost() {
301 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 302 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
302 303
303 base::PlatformFile input_read_handle; 304 base::PlatformFile input_read_handle;
304 base::PlatformFile output_write_handle; 305 base::PlatformFile output_write_handle;
305 306
306 ASSERT_TRUE(MakePipe(&input_read_handle, &input_write_handle_)); 307 ASSERT_TRUE(MakePipe(&input_read_handle, &input_write_handle_));
307 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle)); 308 ASSERT_TRUE(MakePipe(&output_read_handle_, &output_write_handle));
308 309
309 daemon_controller_delegate_ = new MockDaemonControllerDelegate(); 310 daemon_controller_delegate_ = new MockDaemonControllerDelegate();
310 scoped_refptr<DaemonController> daemon_controller( 311 scoped_refptr<DaemonController> daemon_controller(
311 new DaemonController( 312 new DaemonController(
312 scoped_ptr<DaemonController::Delegate>(daemon_controller_delegate_))); 313 scoped_ptr<DaemonController::Delegate>(daemon_controller_delegate_)));
313 314
314 scoped_refptr<PairingRegistry> pairing_registry = 315 scoped_refptr<PairingRegistry> pairing_registry =
315 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>( 316 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>(
316 new MockPairingRegistryDelegate())); 317 new MockPairingRegistryDelegate()));
317 318
318 scoped_ptr<NativeMessagingChannel> channel( 319 scoped_ptr<NativeMessagingChannel> channel(
319 new NativeMessagingChannel(input_read_handle, output_write_handle)); 320 new NativeMessagingChannel(input_read_handle, output_write_handle));
320 321
321 host_.reset(new NativeMessagingHost(channel.Pass(), 322 host_.reset(new Me2MeNativeMessagingHost(channel.Pass(),
322 daemon_controller, 323 daemon_controller,
323 pairing_registry, 324 pairing_registry,
324 scoped_ptr<remoting::OAuthClient>())); 325 scoped_ptr<remoting::OAuthClient>()));
325 host_->Start(base::Bind(&NativeMessagingHostTest::StopHost, 326 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost,
326 base::Unretained(this))); 327 base::Unretained(this)));
327 328
328 // Notify the test that the host has finished starting up. 329 // Notify the test that the host has finished starting up.
329 test_message_loop_->message_loop_proxy()->PostTask( 330 test_message_loop_->message_loop_proxy()->PostTask(
330 FROM_HERE, test_run_loop_->QuitClosure()); 331 FROM_HERE, test_run_loop_->QuitClosure());
331 } 332 }
332 333
333 void NativeMessagingHostTest::StopHost() { 334 void Me2MeNativeMessagingHostTest::StopHost() {
334 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 335 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
335 336
336 host_.reset(); 337 host_.reset();
337 338
338 // Wait till all shutdown tasks have completed. 339 // Wait till all shutdown tasks have completed.
339 base::MessageLoop::current()->RunUntilIdle(); 340 base::MessageLoop::current()->RunUntilIdle();
340 341
341 // Trigger a test shutdown via ExitTest(). 342 // Trigger a test shutdown via ExitTest().
342 host_task_runner_ = NULL; 343 host_task_runner_ = NULL;
343 } 344 }
344 345
345 void NativeMessagingHostTest::ExitTest() { 346 void Me2MeNativeMessagingHostTest::ExitTest() {
346 if (!test_message_loop_->message_loop_proxy()->RunsTasksOnCurrentThread()) { 347 if (!test_message_loop_->message_loop_proxy()->RunsTasksOnCurrentThread()) {
347 test_message_loop_->message_loop_proxy()->PostTask( 348 test_message_loop_->message_loop_proxy()->PostTask(
348 FROM_HERE, 349 FROM_HERE,
349 base::Bind(&NativeMessagingHostTest::ExitTest, 350 base::Bind(&Me2MeNativeMessagingHostTest::ExitTest,
350 base::Unretained(this))); 351 base::Unretained(this)));
351 return; 352 return;
352 } 353 }
353 test_run_loop_->Quit(); 354 test_run_loop_->Quit();
354 } 355 }
355 356
356 void NativeMessagingHostTest::TearDown() { 357 void Me2MeNativeMessagingHostTest::TearDown() {
357 // Closing the write-end of the input will send an EOF to the native 358 // Closing the write-end of the input will send an EOF to the native
358 // messaging reader. This will trigger a host shutdown. 359 // messaging reader. This will trigger a host shutdown.
359 base::ClosePlatformFile(input_write_handle_); 360 base::ClosePlatformFile(input_write_handle_);
360 361
361 // Start a new RunLoop and Wait until the host finishes shutting down. 362 // Start a new RunLoop and Wait until the host finishes shutting down.
362 test_run_loop_.reset(new base::RunLoop()); 363 test_run_loop_.reset(new base::RunLoop());
363 test_run_loop_->Run(); 364 test_run_loop_->Run();
364 365
365 // Verify there are no more message in the output pipe. 366 // Verify there are no more message in the output pipe.
366 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 367 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
367 EXPECT_FALSE(response); 368 EXPECT_FALSE(response);
368 369
369 // The It2MeNativeMessagingHost dtor closes the handles that are passed to it. 370 // The It2MeMe2MeNativeMessagingHost dtor closes the handles that are passed
370 // So the only handle left to close is |output_read_handle_|. 371 // to it. So the only handle left to close is |output_read_handle_|.
371 base::ClosePlatformFile(output_read_handle_); 372 base::ClosePlatformFile(output_read_handle_);
372 } 373 }
373 374
374 scoped_ptr<base::DictionaryValue> 375 scoped_ptr<base::DictionaryValue>
375 NativeMessagingHostTest::ReadMessageFromOutputPipe() { 376 Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
376 uint32 length; 377 uint32 length;
377 int read_result = base::ReadPlatformFileAtCurrentPos( 378 int read_result = base::ReadPlatformFileAtCurrentPos(
378 output_read_handle_, reinterpret_cast<char*>(&length), sizeof(length)); 379 output_read_handle_, reinterpret_cast<char*>(&length), sizeof(length));
379 if (read_result != sizeof(length)) { 380 if (read_result != sizeof(length)) {
380 return scoped_ptr<base::DictionaryValue>(); 381 return scoped_ptr<base::DictionaryValue>();
381 } 382 }
382 383
383 std::string message_json(length, '\0'); 384 std::string message_json(length, '\0');
384 read_result = base::ReadPlatformFileAtCurrentPos( 385 read_result = base::ReadPlatformFileAtCurrentPos(
385 output_read_handle_, string_as_array(&message_json), length); 386 output_read_handle_, string_as_array(&message_json), length);
386 if (read_result != static_cast<int>(length)) { 387 if (read_result != static_cast<int>(length)) {
387 return scoped_ptr<base::DictionaryValue>(); 388 return scoped_ptr<base::DictionaryValue>();
388 } 389 }
389 390
390 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json)); 391 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json));
391 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { 392 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
392 return scoped_ptr<base::DictionaryValue>(); 393 return scoped_ptr<base::DictionaryValue>();
393 } 394 }
394 395
395 return scoped_ptr<base::DictionaryValue>( 396 return scoped_ptr<base::DictionaryValue>(
396 static_cast<base::DictionaryValue*>(message.release())); 397 static_cast<base::DictionaryValue*>(message.release()));
397 } 398 }
398 399
399 void NativeMessagingHostTest::WriteMessageToInputPipe( 400 void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe(
400 const base::Value& message) { 401 const base::Value& message) {
401 std::string message_json; 402 std::string message_json;
402 base::JSONWriter::Write(&message, &message_json); 403 base::JSONWriter::Write(&message, &message_json);
403 404
404 uint32 length = message_json.length(); 405 uint32 length = message_json.length();
405 base::WritePlatformFileAtCurrentPos(input_write_handle_, 406 base::WritePlatformFileAtCurrentPos(input_write_handle_,
406 reinterpret_cast<char*>(&length), 407 reinterpret_cast<char*>(&length),
407 sizeof(length)); 408 sizeof(length));
408 base::WritePlatformFileAtCurrentPos(input_write_handle_, message_json.data(), 409 base::WritePlatformFileAtCurrentPos(input_write_handle_, message_json.data(),
409 length); 410 length);
410 } 411 }
411 412
412 void NativeMessagingHostTest::TestBadRequest(const base::Value& message) { 413 void Me2MeNativeMessagingHostTest::TestBadRequest(const base::Value& message) {
413 base::DictionaryValue good_message; 414 base::DictionaryValue good_message;
414 good_message.SetString("type", "hello"); 415 good_message.SetString("type", "hello");
415 416
416 // This test currently relies on synchronous processing of hello messages and 417 // This test currently relies on synchronous processing of hello messages and
417 // message parameters verification. 418 // message parameters verification.
418 WriteMessageToInputPipe(good_message); 419 WriteMessageToInputPipe(good_message);
419 WriteMessageToInputPipe(message); 420 WriteMessageToInputPipe(message);
420 WriteMessageToInputPipe(good_message); 421 WriteMessageToInputPipe(good_message);
421 422
422 // Read from output pipe, and verify responses. 423 // Read from output pipe, and verify responses.
423 scoped_ptr<base::DictionaryValue> response = 424 scoped_ptr<base::DictionaryValue> response =
424 ReadMessageFromOutputPipe(); 425 ReadMessageFromOutputPipe();
425 VerifyHelloResponse(response.Pass()); 426 VerifyHelloResponse(response.Pass());
426 427
427 response = ReadMessageFromOutputPipe(); 428 response = ReadMessageFromOutputPipe();
428 EXPECT_FALSE(response); 429 EXPECT_FALSE(response);
429 } 430 }
430 431
431 // TODO (weitaosu): crbug.com/323306. Re-enable these tests. 432 // TODO (weitaosu): crbug.com/323306. Re-enable these tests.
432 // Test all valid request-types. 433 // Test all valid request-types.
433 TEST_F(NativeMessagingHostTest, All) { 434 TEST_F(Me2MeNativeMessagingHostTest, All) {
434 int next_id = 0; 435 int next_id = 0;
435 base::DictionaryValue message; 436 base::DictionaryValue message;
436 message.SetInteger("id", next_id++); 437 message.SetInteger("id", next_id++);
437 message.SetString("type", "hello"); 438 message.SetString("type", "hello");
438 WriteMessageToInputPipe(message); 439 WriteMessageToInputPipe(message);
439 440
440 message.SetInteger("id", next_id++); 441 message.SetInteger("id", next_id++);
441 message.SetString("type", "getHostName"); 442 message.SetString("type", "getHostName");
442 WriteMessageToInputPipe(message); 443 WriteMessageToInputPipe(message);
443 444
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // Call the verification routine corresponding to the message id. 511 // Call the verification routine corresponding to the message id.
511 ASSERT_TRUE(verify_routines[id]); 512 ASSERT_TRUE(verify_routines[id]);
512 verify_routines[id](response.Pass()); 513 verify_routines[id](response.Pass());
513 514
514 // Clear the pointer so that the routine cannot be called the second time. 515 // Clear the pointer so that the routine cannot be called the second time.
515 verify_routines[id] = NULL; 516 verify_routines[id] = NULL;
516 } 517 }
517 } 518 }
518 519
519 // Verify that response ID matches request ID. 520 // Verify that response ID matches request ID.
520 TEST_F(NativeMessagingHostTest, Id) { 521 TEST_F(Me2MeNativeMessagingHostTest, Id) {
521 base::DictionaryValue message; 522 base::DictionaryValue message;
522 message.SetString("type", "hello"); 523 message.SetString("type", "hello");
523 WriteMessageToInputPipe(message); 524 WriteMessageToInputPipe(message);
524 message.SetString("id", "42"); 525 message.SetString("id", "42");
525 WriteMessageToInputPipe(message); 526 WriteMessageToInputPipe(message);
526 527
527 scoped_ptr<base::DictionaryValue> response = 528 scoped_ptr<base::DictionaryValue> response =
528 ReadMessageFromOutputPipe(); 529 ReadMessageFromOutputPipe();
529 EXPECT_TRUE(response); 530 EXPECT_TRUE(response);
530 std::string value; 531 std::string value;
531 EXPECT_FALSE(response->GetString("id", &value)); 532 EXPECT_FALSE(response->GetString("id", &value));
532 533
533 response = ReadMessageFromOutputPipe(); 534 response = ReadMessageFromOutputPipe();
534 EXPECT_TRUE(response); 535 EXPECT_TRUE(response);
535 EXPECT_TRUE(response->GetString("id", &value)); 536 EXPECT_TRUE(response->GetString("id", &value));
536 EXPECT_EQ("42", value); 537 EXPECT_EQ("42", value);
537 } 538 }
538 539
539 // Verify non-Dictionary requests are rejected. 540 // Verify non-Dictionary requests are rejected.
540 TEST_F(NativeMessagingHostTest, WrongFormat) { 541 TEST_F(Me2MeNativeMessagingHostTest, WrongFormat) {
541 base::ListValue message; 542 base::ListValue message;
542 TestBadRequest(message); 543 TestBadRequest(message);
543 } 544 }
544 545
545 // Verify requests with no type are rejected. 546 // Verify requests with no type are rejected.
546 TEST_F(NativeMessagingHostTest, MissingType) { 547 TEST_F(Me2MeNativeMessagingHostTest, MissingType) {
547 base::DictionaryValue message; 548 base::DictionaryValue message;
548 TestBadRequest(message); 549 TestBadRequest(message);
549 } 550 }
550 551
551 // Verify rejection if type is unrecognized. 552 // Verify rejection if type is unrecognized.
552 TEST_F(NativeMessagingHostTest, InvalidType) { 553 TEST_F(Me2MeNativeMessagingHostTest, InvalidType) {
553 base::DictionaryValue message; 554 base::DictionaryValue message;
554 message.SetString("type", "xxx"); 555 message.SetString("type", "xxx");
555 TestBadRequest(message); 556 TestBadRequest(message);
556 } 557 }
557 558
558 // Verify rejection if getPinHash request has no hostId. 559 // Verify rejection if getPinHash request has no hostId.
559 TEST_F(NativeMessagingHostTest, GetPinHashNoHostId) { 560 TEST_F(Me2MeNativeMessagingHostTest, GetPinHashNoHostId) {
560 base::DictionaryValue message; 561 base::DictionaryValue message;
561 message.SetString("type", "getPinHash"); 562 message.SetString("type", "getPinHash");
562 message.SetString("pin", "1234"); 563 message.SetString("pin", "1234");
563 TestBadRequest(message); 564 TestBadRequest(message);
564 } 565 }
565 566
566 // Verify rejection if getPinHash request has no pin. 567 // Verify rejection if getPinHash request has no pin.
567 TEST_F(NativeMessagingHostTest, GetPinHashNoPin) { 568 TEST_F(Me2MeNativeMessagingHostTest, GetPinHashNoPin) {
568 base::DictionaryValue message; 569 base::DictionaryValue message;
569 message.SetString("type", "getPinHash"); 570 message.SetString("type", "getPinHash");
570 message.SetString("hostId", "my_host"); 571 message.SetString("hostId", "my_host");
571 TestBadRequest(message); 572 TestBadRequest(message);
572 } 573 }
573 574
574 // Verify rejection if updateDaemonConfig request has invalid config. 575 // Verify rejection if updateDaemonConfig request has invalid config.
575 TEST_F(NativeMessagingHostTest, UpdateDaemonConfigInvalidConfig) { 576 TEST_F(Me2MeNativeMessagingHostTest, UpdateDaemonConfigInvalidConfig) {
576 base::DictionaryValue message; 577 base::DictionaryValue message;
577 message.SetString("type", "updateDaemonConfig"); 578 message.SetString("type", "updateDaemonConfig");
578 message.SetString("config", "xxx"); 579 message.SetString("config", "xxx");
579 TestBadRequest(message); 580 TestBadRequest(message);
580 } 581 }
581 582
582 // Verify rejection if startDaemon request has invalid config. 583 // Verify rejection if startDaemon request has invalid config.
583 TEST_F(NativeMessagingHostTest, StartDaemonInvalidConfig) { 584 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonInvalidConfig) {
584 base::DictionaryValue message; 585 base::DictionaryValue message;
585 message.SetString("type", "startDaemon"); 586 message.SetString("type", "startDaemon");
586 message.SetString("config", "xxx"); 587 message.SetString("config", "xxx");
587 message.SetBoolean("consent", true); 588 message.SetBoolean("consent", true);
588 TestBadRequest(message); 589 TestBadRequest(message);
589 } 590 }
590 591
591 // Verify rejection if startDaemon request has no "consent" parameter. 592 // Verify rejection if startDaemon request has no "consent" parameter.
592 TEST_F(NativeMessagingHostTest, StartDaemonNoConsent) { 593 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) {
593 base::DictionaryValue message; 594 base::DictionaryValue message;
594 message.SetString("type", "startDaemon"); 595 message.SetString("type", "startDaemon");
595 message.Set("config", base::DictionaryValue().DeepCopy()); 596 message.Set("config", base::DictionaryValue().DeepCopy());
596 TestBadRequest(message); 597 TestBadRequest(message);
597 } 598 }
598 599
599 } // namespace remoting 600 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698