Chromium Code Reviews| 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" |
|
msw
2011/11/03 20:25:38
I don't think string_util.h is needed.
alicet1
2011/11/04 22:37:36
Done.
|
| +#include "base/utf_string_conversions.h" |
|
msw
2011/11/03 20:25:38
I don't think utf_string_conversions.h is needed.
alicet1
2011/11/04 22:37:36
Done.
|
| +#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" |
|
msw
2011/11/03 20:25:38
I don't think view.h is needed.
alicet1
2011/11/04 22:37:36
Done.
|
| +#include "views/widget/widget.h" |
| + |
| +#if defined(USE_AURA) |
| +#include "ui/aura/desktop.h" |
| +#endif |
| + |
| +class FirstRunBubbleTest : public testing::Test { |
| + public: |
| + void SetUp() { |
|
msw
2011/11/03 20:25:38
SetUp and TearDown are protected virtual method ov
alicet1
2011/11/04 22:37:36
Done.
|
| + profile_.CreateTemplateURLService(); |
| + MessageLoopForUI::current()->RunAllPending(); |
| + TemplateURLService* turl_model = |
|
msw
2011/11/03 20:25:38
Wow is all this really needed for a TestingProfile
Miranda Callahan
2011/11/03 20:59:39
I don't think you have to do all this -- would it
alicet1
2011/11/04 22:37:36
I tried that route first, and I think it worked ou
|
| + 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_; |
|
msw
2011/11/03 20:25:38
These data members should be made private.
alicet1
2011/11/04 22:37:36
Done.
|
| + TestingProfile profile_; |
| + TemplateURL* default_t_url_; |
| + |
| + void RunPendingMessages() { |
|
msw
2011/11/03 20:25:38
It seems like this function's body could be put di
alicet1
2011/11/04 22:37:36
Done.
|
| +#if defined(USE_AURA) |
|
msw
2011/11/03 20:25:38
Hopefully Ben or someone more familiar with aura t
alicet1
2011/11/04 22:37:36
yeah, this is from views_test_base.h, on how 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(); |
| +} |