OLD | NEW |
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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/webdata/token_service_table.h" | 10 #include "chrome/browser/webdata/token_service_table.h" |
11 #include "chrome/browser/webdata/web_database.h" | 11 #include "chrome/browser/webdata/web_database.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 using base::Time; | 14 using base::Time; |
15 | 15 |
16 class TokenServiceTableTest : public testing::Test { | 16 class TokenServiceTableTest : public testing::Test { |
17 public: | 17 public: |
18 TokenServiceTableTest() {} | 18 TokenServiceTableTest() {} |
19 virtual ~TokenServiceTableTest() {} | 19 virtual ~TokenServiceTableTest() {} |
20 | 20 |
21 protected: | 21 protected: |
22 virtual void SetUp() { | 22 virtual void SetUp() { |
23 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 23 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
24 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); | 24 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); |
25 | 25 |
26 table_.reset(new TokenServiceTable); | 26 table_.reset(new TokenServiceTable); |
27 db_.reset(new WebDatabase); | 27 db_.reset(new WebDatabase); |
28 db_->AddTable(table_.get()); | 28 db_->AddTable(table_.get()); |
29 ASSERT_EQ(sql::INIT_OK, db_->Init(file_, std::string())); | 29 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); |
30 } | 30 } |
31 | 31 |
32 base::FilePath file_; | 32 base::FilePath file_; |
33 base::ScopedTempDir temp_dir_; | 33 base::ScopedTempDir temp_dir_; |
34 scoped_ptr<TokenServiceTable> table_; | 34 scoped_ptr<TokenServiceTable> table_; |
35 scoped_ptr<WebDatabase> db_; | 35 scoped_ptr<WebDatabase> db_; |
36 private: | 36 private: |
37 DISALLOW_COPY_AND_ASSIGN(TokenServiceTableTest); | 37 DISALLOW_COPY_AND_ASSIGN(TokenServiceTableTest); |
38 }; | 38 }; |
39 | 39 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 EXPECT_TRUE(table_->SetTokenForService(service, "")); | 83 EXPECT_TRUE(table_->SetTokenForService(service, "")); |
84 EXPECT_TRUE(table_->GetAllTokens(&out_map)); | 84 EXPECT_TRUE(table_->GetAllTokens(&out_map)); |
85 EXPECT_EQ(out_map.find(service)->second, ""); | 85 EXPECT_EQ(out_map.find(service)->second, ""); |
86 out_map.clear(); | 86 out_map.clear(); |
87 | 87 |
88 // try mutating it | 88 // try mutating it |
89 EXPECT_TRUE(table_->SetTokenForService(service, "ham")); | 89 EXPECT_TRUE(table_->SetTokenForService(service, "ham")); |
90 EXPECT_TRUE(table_->GetAllTokens(&out_map)); | 90 EXPECT_TRUE(table_->GetAllTokens(&out_map)); |
91 EXPECT_EQ(out_map.find(service)->second, "ham"); | 91 EXPECT_EQ(out_map.find(service)->second, "ham"); |
92 } | 92 } |
OLD | NEW |