| Index: chrome/browser/ui/views/first_run_bubble_unittest.cc
|
| diff --git a/chrome/browser/ui/views/first_run_bubble_unittest.cc b/chrome/browser/ui/views/first_run_bubble_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..509318720b1fcebec8c01d9b72f080d177f1e433
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/first_run_bubble_unittest.cc
|
| @@ -0,0 +1,62 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/message_loop.h"
|
| +#include "base/string_util.h"
|
| +#include "base/utf_string_conversions.h"
|
| +#include "chrome/browser/search_engines/template_url.h"
|
| +#include "chrome/browser/search_engines/template_url_service.h"
|
| +#include "chrome/browser/search_engines/template_url_service_factory.h"
|
| +#include "chrome/browser/ui/views/first_run_bubble.h"
|
| +#include "chrome/test/base/testing_profile.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "views/view.h"
|
| +#include "views/widget/widget.h"
|
| +
|
| +#if defined(USE_AURA)
|
| +#include "ui/aura/desktop.h"
|
| +#endif
|
| +
|
| +class FirstRunBubbleTest : public testing::Test {
|
| + public:
|
| + void SetUp() {
|
| + profile_.CreateTemplateURLService();
|
| + MessageLoopForUI::current()->RunAllPending();
|
| + TemplateURLService* turl_model =
|
| + TemplateURLServiceFactory::GetForProfile(&profile_);
|
| + turl_model->Load();
|
| + // Reset the default TemplateURL.
|
| + default_t_url_ = new TemplateURL();
|
| + turl_model->Add(default_t_url_);
|
| + turl_model->SetDefaultSearchProvider(default_t_url_);
|
| + }
|
| +
|
| + MessageLoopForUI message_loop_;
|
| + TestingProfile profile_;
|
| + TemplateURL* default_t_url_;
|
| +
|
| + void RunPendingMessages() {
|
| +#if defined(USE_AURA)
|
| + message_loop_.RunAllPendingWithDispatcher(
|
| + aura::Desktop::GetInstance()->GetDispatcher());
|
| +#else
|
| + message_loop_.RunAllPending();
|
| +#endif
|
| + }
|
| +
|
| + void TearDown() {
|
| + RunPendingMessages();
|
| + }
|
| +};
|
| +
|
| +TEST_F(FirstRunBubbleTest, CreateAndClose) {
|
| + gfx::Rect anchor(10, 20, 0, 0);
|
| + FirstRunBubble* delegate =
|
| + FirstRunBubble::Show(&profile_,
|
| + NULL,
|
| + anchor,
|
| + views::BubbleBorder::TOP_LEFT);
|
| + EXPECT_TRUE(delegate != NULL);
|
| + delegate->GetWidget()->CloseNow();
|
| +}
|
|
|