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

Side by Side Diff: mojo/shell/tests/loader_unittest.cc

Issue 1770533002: Change userid from a uint32_t to a string guid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@33connector
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « mojo/shell/tests/lifecycle/lifecycle_unittest.cc ('k') | mojo/shell/tests/shell/driver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 5 #include <utility>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 InterfaceRequest<TestC> request) override { 382 InterfaceRequest<TestC> request) override {
383 new TestCImpl(connection, context_, std::move(request)); 383 new TestCImpl(connection, context_, std::move(request));
384 } 384 }
385 385
386 TesterContext* context_; 386 TesterContext* context_;
387 scoped_ptr<ShellConnection> app_; 387 scoped_ptr<ShellConnection> app_;
388 std::string requestor_name_; 388 std::string requestor_name_;
389 ScopedVector<TestAImpl> a_bindings_; 389 ScopedVector<TestAImpl> a_bindings_;
390 }; 390 };
391 391
392 void OnConnect(base::RunLoop* loop, uint32_t instance_id, uint32_t user_id) { 392 void OnConnect(base::RunLoop* loop, const String& user_id,
393 uint32_t instance_id) {
393 loop->Quit(); 394 loop->Quit();
394 } 395 }
395 396
396 class LoaderTest : public testing::Test { 397 class LoaderTest : public testing::Test {
397 public: 398 public:
398 LoaderTest() : tester_context_(&loop_) {} 399 LoaderTest() : tester_context_(&loop_) {}
399 ~LoaderTest() override {} 400 ~LoaderTest() override {}
400 401
401 void SetUp() override { 402 void SetUp() override {
402 shell_.reset(new Shell(nullptr, nullptr, nullptr)); 403 shell_.reset(new Shell(nullptr, nullptr, nullptr));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 EXPECT_TRUE(c.encountered_error()); 516 EXPECT_TRUE(c.encountered_error());
516 } 517 }
517 518
518 TEST_F(LoaderTest, TestEndApplicationClosure) { 519 TEST_F(LoaderTest, TestEndApplicationClosure) {
519 ClosingLoader* loader = new ClosingLoader(); 520 ClosingLoader* loader = new ClosingLoader();
520 shell_->SetLoaderForName(scoped_ptr<Loader>(loader), "test:test"); 521 shell_->SetLoaderForName(scoped_ptr<Loader>(loader), "test:test");
521 522
522 bool called = false; 523 bool called = false;
523 scoped_ptr<ConnectParams> params(new ConnectParams); 524 scoped_ptr<ConnectParams> params(new ConnectParams);
524 params->set_source(CreateShellIdentity()); 525 params->set_source(CreateShellIdentity());
525 params->set_target(Identity("test:test", "", mojom::Connector::kUserRoot)); 526 params->set_target(Identity("test:test", "", mojom::kRootUserID));
526 shell_->SetInstanceQuitCallback( 527 shell_->SetInstanceQuitCallback(
527 base::Bind(&QuitClosure, params->target(), &called)); 528 base::Bind(&QuitClosure, params->target(), &called));
528 shell_->Connect(std::move(params)); 529 shell_->Connect(std::move(params));
529 loop_.Run(); 530 loop_.Run();
530 EXPECT_TRUE(called); 531 EXPECT_TRUE(called);
531 } 532 }
532 533
533 TEST_F(LoaderTest, SameIdentityShouldNotCauseDuplicateLoad) { 534 TEST_F(LoaderTest, SameIdentityShouldNotCauseDuplicateLoad) {
534 // 1 because LoaderTest connects once at startup. 535 // 1 because LoaderTest connects once at startup.
535 EXPECT_EQ(1, test_loader_->num_loads()); 536 EXPECT_EQ(1, test_loader_->num_loads());
536 537
537 TestServicePtr test_service; 538 TestServicePtr test_service;
538 ConnectToInterface("test:foo", &test_service); 539 ConnectToInterface("test:foo", &test_service);
539 EXPECT_EQ(2, test_loader_->num_loads()); 540 EXPECT_EQ(2, test_loader_->num_loads());
540 541
541 // Exactly the same name as above. 542 // Exactly the same name as above.
542 ConnectToInterface("test:foo", &test_service); 543 ConnectToInterface("test:foo", &test_service);
543 EXPECT_EQ(2, test_loader_->num_loads()); 544 EXPECT_EQ(2, test_loader_->num_loads());
544 545
545 // A different identity because the domain is different. 546 // A different identity because the domain is different.
546 ConnectToInterface("test:bar", &test_service); 547 ConnectToInterface("test:bar", &test_service);
547 EXPECT_EQ(3, test_loader_->num_loads()); 548 EXPECT_EQ(3, test_loader_->num_loads());
548 } 549 }
549 550
550 } // namespace test 551 } // namespace test
551 } // namespace shell 552 } // namespace shell
552 } // namespace mojo 553 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/tests/lifecycle/lifecycle_unittest.cc ('k') | mojo/shell/tests/shell/driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698