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/macros.h" | 5 #include "base/macros.h" |
6 #include "chrome/browser/search_engines/template_url_service_factory.h" | 6 #include "chrome/browser/search_engines/template_url_service_factory.h" |
7 #include "chrome/browser/ui/views/first_run_bubble.h" | 7 #include "chrome/browser/ui/views/first_run_bubble.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "components/search_engines/template_url.h" | 9 #include "components/search_engines/template_url.h" |
10 #include "components/search_engines/template_url_service.h" | 10 #include "components/search_engines/template_url_service.h" |
| 11 #include "content/public/test/test_browser_thread.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
15 #include "ui/events/event_processor.h" | 16 #include "ui/events/event_processor.h" |
16 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
17 #include "ui/views/test/views_test_base.h" | 18 #include "ui/views/test/views_test_base.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 | 21 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 // Overrides from views::ViewsTestBase: | 61 // Overrides from views::ViewsTestBase: |
61 void SetUp() override; | 62 void SetUp() override; |
62 | 63 |
63 void CreateAndCloseBubbleOnEventTest(ui::Event* event); | 64 void CreateAndCloseBubbleOnEventTest(ui::Event* event); |
64 | 65 |
65 protected: | 66 protected: |
66 TestingProfile* profile() { return &profile_; } | 67 TestingProfile* profile() { return &profile_; } |
67 | 68 |
68 private: | 69 private: |
| 70 // TestBrowserThreadBundle cannot be used here because the ViewsTestBase |
| 71 // superclass creates its own MessageLoop. |
| 72 content::TestBrowserThread ui_thread_; |
69 TestingProfile profile_; | 73 TestingProfile profile_; |
70 | 74 |
71 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleTest); | 75 DISALLOW_COPY_AND_ASSIGN(FirstRunBubbleTest); |
72 }; | 76 }; |
73 | 77 |
74 FirstRunBubbleTest::FirstRunBubbleTest() {} | 78 FirstRunBubbleTest::FirstRunBubbleTest() |
| 79 : ui_thread_(content::BrowserThread::UI, base::MessageLoop::current()) {} |
75 | 80 |
76 FirstRunBubbleTest::~FirstRunBubbleTest() {} | 81 FirstRunBubbleTest::~FirstRunBubbleTest() {} |
77 | 82 |
78 void FirstRunBubbleTest::SetUp() { | 83 void FirstRunBubbleTest::SetUp() { |
79 ViewsTestBase::SetUp(); | 84 ViewsTestBase::SetUp(); |
80 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 85 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
81 profile(), &TemplateURLServiceFactory::BuildInstanceFor); | 86 profile(), &TemplateURLServiceFactory::BuildInstanceFor); |
82 TemplateURLService* turl_model = | 87 TemplateURLService* turl_model = |
83 TemplateURLServiceFactory::GetForProfile(profile()); | 88 TemplateURLServiceFactory::GetForProfile(profile()); |
84 turl_model->Load(); | 89 turl_model->Load(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 146 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
142 CreateAndCloseBubbleOnEventTest(&mouse_down); | 147 CreateAndCloseBubbleOnEventTest(&mouse_down); |
143 } | 148 } |
144 | 149 |
145 TEST_F(FirstRunBubbleTest, CloseBubbleOnTouchDownEvent) { | 150 TEST_F(FirstRunBubbleTest, CloseBubbleOnTouchDownEvent) { |
146 ui::TouchEvent touch_down( | 151 ui::TouchEvent touch_down( |
147 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); | 152 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow()); |
148 CreateAndCloseBubbleOnEventTest(&touch_down); | 153 CreateAndCloseBubbleOnEventTest(&touch_down); |
149 } | 154 } |
150 | 155 |
OLD | NEW |