Commit 8c68557a authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

Remove local test timeouts in SearchHistoryTest.

BUG=385198

Review URL: https://codereview.chromium.org/337393002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277882 0039d316-1c4b-4281-b951-d872f2087c98
parent 993f4bbe
......@@ -9,7 +9,6 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "base/timer/timer.h"
#include "chrome/browser/ui/app_list/search/history.h"
#include "chrome/browser/ui/app_list/search/history_data.h"
#include "chrome/browser/ui/app_list/search/history_data_observer.h"
......@@ -35,14 +34,9 @@ class HistoryDataLoadWaiter : public HistoryDataObserver {
explicit HistoryDataLoadWaiter(HistoryData* data) : data_(data) {}
virtual ~HistoryDataLoadWaiter() {}
void Wait(int timeout_ms) {
void Wait() {
data_->AddObserver(this);
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(timeout_ms),
this,
&HistoryDataLoadWaiter::OnTimeOut);
run_loop_.reset(new base::RunLoop);
run_loop_->Run();
......@@ -50,10 +44,6 @@ class HistoryDataLoadWaiter : public HistoryDataObserver {
}
private:
void OnTimeOut() {
run_loop_->Quit();
}
// HistoryDataObserver overrides:
virtual void OnHistoryDataLoadedFromStore() OVERRIDE {
run_loop_->Quit();
......@@ -61,7 +51,6 @@ class HistoryDataLoadWaiter : public HistoryDataObserver {
HistoryData* data_; // Not owned.
scoped_ptr<base::RunLoop> run_loop_;
base::OneShotTimer<HistoryDataLoadWaiter> timer_;
DISALLOW_COPY_AND_ASSIGN(HistoryDataLoadWaiter);
};
......@@ -75,31 +64,21 @@ class StoreFlushWaiter {
explicit StoreFlushWaiter(HistoryDataStore* store) : store_(store) {}
~StoreFlushWaiter() {}
void Wait(int timeout_ms) {
void Wait() {
store_->Flush(
base::Bind(&StoreFlushWaiter::OnFlushed, base::Unretained(this)));
timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(timeout_ms),
this,
&StoreFlushWaiter::OnTimeOut);
run_loop_.reset(new base::RunLoop);
run_loop_->Run();
}
private:
void OnTimeOut() {
run_loop_->Quit();
}
void OnFlushed() {
run_loop_->Quit();
}
HistoryDataStore* store_; // Not owned.
scoped_ptr<base::RunLoop> run_loop_;
base::OneShotTimer<StoreFlushWaiter> timer_;
DISALLOW_COPY_AND_ASSIGN(StoreFlushWaiter);
};
......@@ -130,14 +109,12 @@ class SearchHistoryTest : public testing::Test {
new HistoryData(history_->store_.get(), kMaxPrimary, kMaxSecondary));
history_->data_->AddObserver(history_.get());
HistoryDataLoadWaiter waiter(history_->data_.get());
waiter.Wait(1000);
HistoryDataLoadWaiter(history_->data_.get()).Wait();
ASSERT_TRUE(history_->IsReady());
}
void Flush() {
StoreFlushWaiter waiter(history_->store_.get());
waiter.Wait(1000);
StoreFlushWaiter(history_->store_.get()).Wait();
}
size_t GetKnownResults(const std::string& query) {
......
......@@ -6312,18 +6312,6 @@
fun:_ZN8chromeos21DeviceSettingsService11EnqueueLoadEb
fun:_ZN8chromeos21DeviceSettingsService4LoadEv
}
{
bug_385198
Memcheck:Leak
fun:_Znw*
fun:_ZN4base8internal20PostTaskAndReplyImpl16PostTaskAndReplyERKN15tracked_objects8LocationERKNS_8CallbackIFvvEEESA_
fun:_ZN4base10TaskRunner16PostTaskAndReplyERKN15tracked_objects8LocationERKNS_8CallbackIFvvEEES9_
fun:_ZN8app_list19DictionaryDataStore5FlushERKN4base8CallbackIFvvEEE
fun:_ZN8app_list16HistoryDataStore5FlushERKN4base8CallbackIFvvEEE
fun:_ZN8app_list4test12_GLOBAL__N_116StoreFlushWaiter4WaitEi
fun:_ZN8app_list4test17SearchHistoryTest5FlushEv
fun:_ZN8app_list4test17SearchHistoryTest8TearDownEv
}
{
bug_385381
Memcheck:Unaddressable
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment