OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "accounts_db_manager.h" | 5 #include "accounts_db_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_tokenizer.h" | 8 #include "base/strings/string_tokenizer.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | |
10 #include "mojo/public/cpp/application/application_test_base.h" | 9 #include "mojo/public/cpp/application/application_test_base.h" |
11 #include "mojo/public/cpp/application/connect.h" | 10 #include "mojo/public/cpp/application/connect.h" |
12 #include "mojo/services/files/interfaces/types.mojom.h" | 11 #include "mojo/services/files/interfaces/types.mojom.h" |
13 #include "services/authentication/credentials_impl_db.mojom.h" | 12 #include "services/authentication/credentials_impl_db.mojom.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 namespace authentication { | 15 namespace authentication { |
17 namespace { | 16 namespace { |
18 | 17 |
19 class AccountsDBTest : public mojo::test::ApplicationTestBase { | 18 class AccountsDBTest : public mojo::test::ApplicationTestBase { |
20 public: | 19 public: |
21 AccountsDBTest(){}; | 20 AccountsDBTest(){}; |
22 ~AccountsDBTest() override{}; | 21 ~AccountsDBTest() override{}; |
23 | 22 |
24 protected: | 23 protected: |
25 void SetUp() override { | 24 void SetUp() override { |
26 mojo::test::ApplicationTestBase::SetUp(); | 25 mojo::test::ApplicationTestBase::SetUp(); |
27 mojo::files::FilesPtr files; | 26 mojo::files::FilesPtr files; |
28 mojo::ConnectToService(application_impl()->shell(), "mojo:files", | 27 mojo::ConnectToService(shell(), "mojo:files", GetProxy(&files)); |
29 GetProxy(&files)); | |
30 | 28 |
31 mojo::files::Error error = mojo::files::Error::INTERNAL; | 29 mojo::files::Error error = mojo::files::Error::INTERNAL; |
32 mojo::files::DirectoryPtr directory; | 30 mojo::files::DirectoryPtr directory; |
33 files->OpenFileSystem(nullptr, GetProxy(&directory), | 31 files->OpenFileSystem(nullptr, GetProxy(&directory), |
34 [&error](mojo::files::Error e) { error = e; }); | 32 [&error](mojo::files::Error e) { error = e; }); |
35 CHECK(files.WaitForIncomingResponse()); | 33 CHECK(files.WaitForIncomingResponse()); |
36 CHECK_EQ(mojo::files::Error::OK, error); | 34 CHECK_EQ(mojo::files::Error::OK, error); |
37 | 35 |
38 accounts_db_manager_ = new AccountsDbManager(directory.Pass()); | 36 accounts_db_manager_ = new AccountsDbManager(directory.Pass()); |
39 } | 37 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 151 } |
154 | 152 |
155 TEST_F(AccountsDBTest, CanGetAuthorizedUserForInvalidApp) { | 153 TEST_F(AccountsDBTest, CanGetAuthorizedUserForInvalidApp) { |
156 accountsDBPtr()->UpdateAuthorization("url1", "user1"); | 154 accountsDBPtr()->UpdateAuthorization("url1", "user1"); |
157 ASSERT_TRUE( | 155 ASSERT_TRUE( |
158 accountsDBPtr()->GetAuthorizedUserForApp("invalid_app_url").is_null()); | 156 accountsDBPtr()->GetAuthorizedUserForApp("invalid_app_url").is_null()); |
159 } | 157 } |
160 | 158 |
161 } // namespace | 159 } // namespace |
162 } // namespace authentication | 160 } // namespace authentication |
OLD | NEW |