OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h" | 5 #include "chrome/browser/ui/views/apps/app_info_dialog/app_info_dialog_views.h" |
6 | 6 |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 class AppInfoDialogViewsTest : public ash::test::AshTestBase, | 33 class AppInfoDialogViewsTest : public ash::test::AshTestBase, |
34 public views::WidgetObserver { | 34 public views::WidgetObserver { |
35 public: | 35 public: |
36 AppInfoDialogViewsTest() | 36 AppInfoDialogViewsTest() |
37 : widget_(NULL), | 37 : widget_(NULL), |
38 widget_destroyed_(false), | 38 widget_destroyed_(false), |
39 command_line_(CommandLine::NO_PROGRAM) {} | 39 command_line_(CommandLine::NO_PROGRAM) {} |
40 virtual ~AppInfoDialogViewsTest() {} | 40 virtual ~AppInfoDialogViewsTest() {} |
41 | 41 |
42 // Overridden from testing::Test: | 42 // Overridden from testing::Test: |
43 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() override { |
44 ash::test::AshTestBase::SetUp(); | 44 ash::test::AshTestBase::SetUp(); |
45 | 45 |
46 widget_ = views::DialogDelegate::CreateDialogWidget( | 46 widget_ = views::DialogDelegate::CreateDialogWidget( |
47 new views::DialogDelegateView(), CurrentContext(), NULL); | 47 new views::DialogDelegateView(), CurrentContext(), NULL); |
48 widget_->AddObserver(this); | 48 widget_->AddObserver(this); |
49 | 49 |
50 profile_.reset(new TestingProfile()); | 50 profile_.reset(new TestingProfile()); |
51 CreateExtensionSystemForProfile(profile_.get()); | 51 CreateExtensionSystemForProfile(profile_.get()); |
52 | 52 |
53 app_ = extensions::ExtensionBuilder() | 53 app_ = extensions::ExtensionBuilder() |
54 .SetManifest(ValidAppManifest()) | 54 .SetManifest(ValidAppManifest()) |
55 .SetID(kTestExtensionId) | 55 .SetID(kTestExtensionId) |
56 .Build(); | 56 .Build(); |
57 InstallApp(profile_.get(), app_.get()); | 57 InstallApp(profile_.get(), app_.get()); |
58 | 58 |
59 dialog_ = new AppInfoDialog( | 59 dialog_ = new AppInfoDialog( |
60 widget_->GetNativeWindow(), profile_.get(), app_.get()); | 60 widget_->GetNativeWindow(), profile_.get(), app_.get()); |
61 widget_->GetContentsView()->AddChildView(dialog_); | 61 widget_->GetContentsView()->AddChildView(dialog_); |
62 } | 62 } |
63 | 63 |
64 virtual void TearDown() OVERRIDE { | 64 virtual void TearDown() override { |
65 if (!widget_destroyed_) | 65 if (!widget_destroyed_) |
66 widget_->CloseNow(); | 66 widget_->CloseNow(); |
67 widget_ = NULL; | 67 widget_ = NULL; |
68 profile_.reset(); | 68 profile_.reset(); |
69 ash::test::AshTestBase::TearDown(); | 69 ash::test::AshTestBase::TearDown(); |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 // Overridden from views::WidgetObserver: | 73 // Overridden from views::WidgetObserver: |
74 virtual void OnWidgetDestroyed(views::Widget* widget) OVERRIDE { | 74 virtual void OnWidgetDestroyed(views::Widget* widget) override { |
75 widget_destroyed_ = true; | 75 widget_destroyed_ = true; |
76 widget_->RemoveObserver(this); | 76 widget_->RemoveObserver(this); |
77 widget_ = NULL; | 77 widget_ = NULL; |
78 } | 78 } |
79 | 79 |
80 void CreateExtensionSystemForProfile(Profile* profile) { | 80 void CreateExtensionSystemForProfile(Profile* profile) { |
81 extensions::TestExtensionSystem* test_extension_system = | 81 extensions::TestExtensionSystem* test_extension_system = |
82 static_cast<extensions::TestExtensionSystem*>( | 82 static_cast<extensions::TestExtensionSystem*>( |
83 extensions::ExtensionSystem::Get(profile)); | 83 extensions::ExtensionSystem::Get(profile)); |
84 test_extension_system->CreateExtensionService( | 84 test_extension_system->CreateExtensionService( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 .SetID(kTestOtherExtensionId) | 188 .SetID(kTestOtherExtensionId) |
189 .Build(); | 189 .Build(); |
190 InstallApp(other_profile.get(), other_app.get()); | 190 InstallApp(other_profile.get(), other_app.get()); |
191 | 191 |
192 EXPECT_FALSE(widget_->IsClosed()); | 192 EXPECT_FALSE(widget_->IsClosed()); |
193 EXPECT_FALSE(widget_destroyed_); | 193 EXPECT_FALSE(widget_destroyed_); |
194 other_profile.reset(); | 194 other_profile.reset(); |
195 RunAllPendingInMessageLoop(); | 195 RunAllPendingInMessageLoop(); |
196 EXPECT_FALSE(widget_destroyed_); | 196 EXPECT_FALSE(widget_destroyed_); |
197 } | 197 } |
OLD | NEW |