| OLD | NEW |
| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
| 12 #include "chrome/browser/ui/app_list/search/common/dictionary_data_store.h" |
| 12 #include "chrome/browser/ui/app_list/search/history.h" | 13 #include "chrome/browser/ui/app_list/search/history.h" |
| 13 #include "chrome/browser/ui/app_list/search/history_data.h" | 14 #include "chrome/browser/ui/app_list/search/history_data.h" |
| 14 #include "chrome/browser/ui/app_list/search/history_data_observer.h" | 15 #include "chrome/browser/ui/app_list/search/history_data_observer.h" |
| 15 #include "chrome/browser/ui/app_list/search/history_data_store.h" | 16 #include "chrome/browser/ui/app_list/search/history_data_store.h" |
| 17 #include "chrome/browser/ui/app_list/search/history_factory.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 21 |
| 20 namespace app_list { | 22 namespace app_list { |
| 21 namespace test { | 23 namespace test { |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 const size_t kMaxPrimary = 3; | 27 const size_t kMaxPrimary = 3; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // testing::Test overrides: | 96 // testing::Test overrides: |
| 95 virtual void SetUp() OVERRIDE { | 97 virtual void SetUp() OVERRIDE { |
| 96 profile_.reset(new TestingProfile); | 98 profile_.reset(new TestingProfile); |
| 97 CreateHistory(); | 99 CreateHistory(); |
| 98 } | 100 } |
| 99 virtual void TearDown() OVERRIDE { | 101 virtual void TearDown() OVERRIDE { |
| 100 Flush(); | 102 Flush(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 void CreateHistory() { | 105 void CreateHistory() { |
| 104 history_.reset(new History(profile_.get())); | 106 const char kStoreDataFileName[] = "app-launcher-test"; |
| 107 const base::FilePath data_file = |
| 108 profile_->GetPath().AppendASCII(kStoreDataFileName); |
| 109 scoped_refptr<DictionaryDataStore> dictionary_data_store( |
| 110 new DictionaryDataStore(data_file)); |
| 111 history_.reset(new History(scoped_refptr<HistoryDataStore>( |
| 112 new HistoryDataStore(dictionary_data_store)))); |
| 105 | 113 |
| 106 // Replace |data_| with test params. | 114 // Replace |data_| with test params. |
| 107 history_->data_->RemoveObserver(history_.get()); | 115 history_->data_->RemoveObserver(history_.get()); |
| 108 history_->data_.reset( | 116 history_->data_.reset( |
| 109 new HistoryData(history_->store_.get(), kMaxPrimary, kMaxSecondary)); | 117 new HistoryData(history_->store_.get(), kMaxPrimary, kMaxSecondary)); |
| 110 history_->data_->AddObserver(history_.get()); | 118 history_->data_->AddObserver(history_.get()); |
| 111 | 119 |
| 112 HistoryDataLoadWaiter(history_->data_.get()).Wait(); | 120 HistoryDataLoadWaiter(history_->data_.get()).Wait(); |
| 113 ASSERT_TRUE(history_->IsReady()); | 121 ASSERT_TRUE(history_->IsReady()); |
| 114 } | 122 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 294 |
| 287 // The oldest secondary is gone. | 295 // The oldest secondary is gone. |
| 288 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1")); | 296 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1")); |
| 289 | 297 |
| 290 // Touched oldest survived. | 298 // Touched oldest survived. |
| 291 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0")); | 299 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0")); |
| 292 } | 300 } |
| 293 | 301 |
| 294 } // namespace test | 302 } // namespace test |
| 295 } // namespace app_list | 303 } // namespace app_list |
| OLD | NEW |