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

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_apitest.cc

Issue 2348723002: [Extensions] Remove UIThreadExtensionFunction::DelegateForTests (Closed)
Patch Set: lazyboy's Created 4 years, 3 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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/timer/mock_timer.h" 9 #include "base/timer/mock_timer.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysInvalid) { 470 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysInvalid) {
471 scoped_refptr<Extension> empty_extension( 471 scoped_refptr<Extension> empty_extension(
472 extensions::test_util::CreateEmptyExtension()); 472 extensions::test_util::CreateEmptyExtension());
473 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction> 473 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction>
474 cast_channel_set_authority_keys_function; 474 cast_channel_set_authority_keys_function;
475 // TODO(eroman): crbug.com/601171: Delete this test once the API has 475 // TODO(eroman): crbug.com/601171: Delete this test once the API has
476 // been removed. The API is deprecated and will trivially return 476 // been removed. The API is deprecated and will trivially return
477 // success. So this is just testing that it succeeds for all inputs 477 // success. So this is just testing that it succeeds for all inputs
478 // (even invalid ones). 478 // (even invalid ones).
479 std::string errorResult = ""; 479 cast_channel_set_authority_keys_function =
480 CreateSetAuthorityKeysFunction(empty_extension);
481 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
482 "[\"\", \"signature\"]", browser(),
483 utils::NONE));
480 484
481 cast_channel_set_authority_keys_function = 485 cast_channel_set_authority_keys_function =
482 CreateSetAuthorityKeysFunction(empty_extension); 486 CreateSetAuthorityKeysFunction(empty_extension);
483 std::string error = utils::RunFunctionAndReturnError( 487 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
484 cast_channel_set_authority_keys_function.get(), 488 "[\"keys\", \"\"]", browser(), utils::NONE));
485 "[\"\", \"signature\"]",
486 browser());
487 EXPECT_EQ(error, errorResult);
488
489 cast_channel_set_authority_keys_function =
490 CreateSetAuthorityKeysFunction(empty_extension);
491 error = utils::RunFunctionAndReturnError(
492 cast_channel_set_authority_keys_function.get(),
493 "[\"keys\", \"\"]",
494 browser());
495 EXPECT_EQ(error, errorResult);
496 489
497 std::string keys = 490 std::string keys =
498 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL" 491 "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL"
499 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg" 492 "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg"
500 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv" 493 "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv"
501 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g" 494 "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g"
502 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk" 495 "QBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3TOmZer5ufk"
503 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ=="; 496 "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ==";
504 std::string signature = 497 std::string signature =
505 "chCUHZKkykcwU8HzU+hm027fUTBL0dqPMtrzppwExQwK9+" 498 "chCUHZKkykcwU8HzU+hm027fUTBL0dqPMtrzppwExQwK9+"
506 "XlmCjJswfce2sUUfhR1OL1tyW4hWFwu4JnuQCJ+CvmSmAh2bzRpnuSKzBfgvIDjNOAGUs7" 499 "XlmCjJswfce2sUUfhR1OL1tyW4hWFwu4JnuQCJ+CvmSmAh2bzRpnuSKzBfgvIDjNOAGUs7"
507 "ADaNSSWPLxp+6ko++2Dn4S9HpOt8N1v6gMWqj3Ru5IqFSQPZSvGH2ois6uE50CFayPcjQE" 500 "ADaNSSWPLxp+6ko++2Dn4S9HpOt8N1v6gMWqj3Ru5IqFSQPZSvGH2ois6uE50CFayPcjQE"
508 "OVZt41noQdFd15RmKTvocoCC5tHNlaikeQ52yi0IScOlad1B1lMhoplW3rWophQaqxMumr" 501 "OVZt41noQdFd15RmKTvocoCC5tHNlaikeQ52yi0IScOlad1B1lMhoplW3rWophQaqxMumr"
509 "OcHIZ+Y+p858x5f8Pny/kuqUClmFh9B/vF07NsUHwoSL9tA5t5jCY3L5iUc/v7o3oFcW/T" 502 "OcHIZ+Y+p858x5f8Pny/kuqUClmFh9B/vF07NsUHwoSL9tA5t5jCY3L5iUc/v7o3oFcW/T"
510 "gojKkX2Kg7KQ86QA=="; 503 "gojKkX2Kg7KQ86QA==";
511 504
512 cast_channel_set_authority_keys_function = 505 cast_channel_set_authority_keys_function =
513 CreateSetAuthorityKeysFunction(empty_extension); 506 CreateSetAuthorityKeysFunction(empty_extension);
514 error = utils::RunFunctionAndReturnError( 507 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
515 cast_channel_set_authority_keys_function.get(), 508 "[\"" + keys + "\", \"signature\"]", browser(),
516 "[\"" + keys + "\", \"signature\"]", 509 utils::NONE));
517 browser());
518 EXPECT_EQ(error, errorResult);
519 510
520 cast_channel_set_authority_keys_function = 511 cast_channel_set_authority_keys_function =
521 CreateSetAuthorityKeysFunction(empty_extension); 512 CreateSetAuthorityKeysFunction(empty_extension);
522 error = utils::RunFunctionAndReturnError( 513 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
523 cast_channel_set_authority_keys_function.get(), 514 "[\"keys\", \"" + signature + "\"]", browser(),
524 "[\"keys\", \"" + signature + "\"]", 515 utils::NONE));
525 browser());
526 EXPECT_EQ(error, errorResult);
527 516
528 cast_channel_set_authority_keys_function = 517 cast_channel_set_authority_keys_function =
529 CreateSetAuthorityKeysFunction(empty_extension); 518 CreateSetAuthorityKeysFunction(empty_extension);
530 error = utils::RunFunctionAndReturnError( 519 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
531 cast_channel_set_authority_keys_function.get(), 520 "[\"" + keys + "\", \"" + signature + "\"]",
532 "[\"" + keys + "\", \"" + signature + "\"]", 521 browser(), utils::NONE));
533 browser());
534 EXPECT_EQ(error, errorResult);
535 } 522 }
536 523
537 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysValid) { 524 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSetAuthorityKeysValid) {
538 scoped_refptr<Extension> empty_extension( 525 scoped_refptr<Extension> empty_extension(
539 extensions::test_util::CreateEmptyExtension()); 526 extensions::test_util::CreateEmptyExtension());
540 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction> 527 scoped_refptr<extensions::CastChannelSetAuthorityKeysFunction>
541 cast_channel_set_authority_keys_function; 528 cast_channel_set_authority_keys_function;
542 529
543 cast_channel_set_authority_keys_function = 530 cast_channel_set_authority_keys_function =
544 CreateSetAuthorityKeysFunction(empty_extension); 531 CreateSetAuthorityKeysFunction(empty_extension);
(...skipping 11 matching lines...) Expand all
556 "gkSW9LWVYE6l3yc9QVwHo7Q1WrOe8gUkys0xWg0mTNTT/VDhNOlMgVgwssd63YGJptQ6OI" 543 "gkSW9LWVYE6l3yc9QVwHo7Q1WrOe8gUkys0xWg0mTNTT/VDhNOlMgVgwssd63YGJptQ6OI"
557 "QDtzSedz//eAdbmcGyHzVWbjo8DCXhV/aKfknAzIMRNeeRbS5lAgMBAAE="; 544 "QDtzSedz//eAdbmcGyHzVWbjo8DCXhV/aKfknAzIMRNeeRbS5lAgMBAAE=";
558 std::string signature = 545 std::string signature =
559 "o83oku3jP+xjTysNBalqp/ZfJRPLt8R+IUhZMepbARFSRVizLoeFW5XyUwe6lQaC+PFFQH" 546 "o83oku3jP+xjTysNBalqp/ZfJRPLt8R+IUhZMepbARFSRVizLoeFW5XyUwe6lQaC+PFFQH"
560 "SZeGZyeeGRpwCJ/lef0xh6SWJlVMWNTk5+z0U84GQdizJP/CTCeHpIwMobN+kyDajgOyfD" 547 "SZeGZyeeGRpwCJ/lef0xh6SWJlVMWNTk5+z0U84GQdizJP/CTCeHpIwMobN+kyDajgOyfD"
561 "DLhktc6LHmSlFGG6J7B8W67oziS8ZFEdrcT9WSXFrjLVyURHjvidZD5iFtuImI6k9R9OoX" 548 "DLhktc6LHmSlFGG6J7B8W67oziS8ZFEdrcT9WSXFrjLVyURHjvidZD5iFtuImI6k9R9OoX"
562 "LR6SyAwpjdrL+vlHMk3Gol6KQ98YpF0ghHnN3/FFW4ibvIwjmRbp+tUV3h8TRcCOjlXVGp" 549 "LR6SyAwpjdrL+vlHMk3Gol6KQ98YpF0ghHnN3/FFW4ibvIwjmRbp+tUV3h8TRcCOjlXVGp"
563 "bzPtNRRlTqfv7Rxm5YXkZMLmJJMZiTs5+o8FMRMTQZT4hRR3DQ+A/jofViyTGA=="; 550 "bzPtNRRlTqfv7Rxm5YXkZMLmJJMZiTs5+o8FMRMTQZT4hRR3DQ+A/jofViyTGA==";
564 551
565 std::string args = "[\"" + keys + "\", \"" + signature + "\"]"; 552 std::string args = "[\"" + keys + "\", \"" + signature + "\"]";
566 std::string error = utils::RunFunctionAndReturnError( 553 EXPECT_TRUE(utils::RunFunction(cast_channel_set_authority_keys_function.get(),
567 cast_channel_set_authority_keys_function.get(), args, browser()); 554 args, browser(), utils::NONE));
568 EXPECT_EQ(error, std::string());
569 } 555 }
570 556
571 // TODO(vadimgo): Win Dbg has a workaround that makes RunExtensionSubtest 557 // TODO(vadimgo): Win Dbg has a workaround that makes RunExtensionSubtest
572 // always return true without actually running the test. Remove when fixed. 558 // always return true without actually running the test. Remove when fixed.
573 #if defined(OS_WIN) && !defined(NDEBUG) 559 #if defined(OS_WIN) && !defined(NDEBUG)
574 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys 560 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys
575 #else 561 #else
576 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys 562 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys
577 #endif 563 #endif
578 // Test loading extension, opening a channel with ConnectInfo, adding a 564 // Test loading extension, opening a channel with ConnectInfo, adding a
579 // listener, writing, reading, and closing. 565 // listener, writing, reading, and closing.
580 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) { 566 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) {
581 EXPECT_TRUE( 567 EXPECT_TRUE(
582 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html")); 568 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html"));
583 } 569 }
OLDNEW
« no previous file with comments | « extensions/browser/api/bluetooth/bluetooth_apitest.cc ('k') | extensions/browser/api_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698