Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: athena/content/app_activity_unittest.cc

Issue 641683003: C++11 override style change for athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "athena/activity/public/activity_factory.h" 5 #include "athena/activity/public/activity_factory.h"
6 #include "athena/activity/public/activity_manager.h" 6 #include "athena/activity/public/activity_manager.h"
7 #include "athena/content/app_activity.h" 7 #include "athena/content/app_activity.h"
8 #include "athena/content/app_activity_registry.h" 8 #include "athena/content/app_activity_registry.h"
9 #include "athena/content/public/app_registry.h" 9 #include "athena/content/public/app_registry.h"
10 #include "athena/extensions/public/extensions_delegate.h" 10 #include "athena/extensions/public/extensions_delegate.h"
(...skipping 22 matching lines...) Expand all
33 class TestAppActivity : public AppActivity { 33 class TestAppActivity : public AppActivity {
34 public: 34 public:
35 explicit TestAppActivity(const std::string& app_id) 35 explicit TestAppActivity(const std::string& app_id)
36 : AppActivity(app_id), 36 : AppActivity(app_id),
37 view_(new views::View()), 37 view_(new views::View()),
38 current_state_(ACTIVITY_VISIBLE) { 38 current_state_(ACTIVITY_VISIBLE) {
39 app_activity_registry_ = 39 app_activity_registry_ =
40 AppRegistry::Get()->GetAppActivityRegistry(app_id, NULL); 40 AppRegistry::Get()->GetAppActivityRegistry(app_id, NULL);
41 app_activity_registry_->RegisterAppActivity(this); 41 app_activity_registry_->RegisterAppActivity(this);
42 } 42 }
43 virtual ~TestAppActivity() { 43 ~TestAppActivity() override {
44 app_activity_registry_->UnregisterAppActivity(this); 44 app_activity_registry_->UnregisterAppActivity(this);
45 } 45 }
46 46
47 AppActivityRegistry* app_activity_registry() { 47 AppActivityRegistry* app_activity_registry() {
48 return app_activity_registry_; 48 return app_activity_registry_;
49 } 49 }
50 50
51 // Activity: 51 // Activity:
52 virtual ActivityViewModel* GetActivityViewModel() override { 52 ActivityViewModel* GetActivityViewModel() override {
53 return this; 53 return this;
54 } 54 }
55 virtual void SetCurrentState(Activity::ActivityState state) override { 55 void SetCurrentState(Activity::ActivityState state) override {
56 current_state_ = state; 56 current_state_ = state;
57 if (state == ACTIVITY_UNLOADED) 57 if (state == ACTIVITY_UNLOADED)
58 app_activity_registry_->Unload(); 58 app_activity_registry_->Unload();
59 } 59 }
60 virtual ActivityState GetCurrentState() override { 60 ActivityState GetCurrentState() override {
61 return current_state_; 61 return current_state_;
62 } 62 }
63 virtual bool IsVisible() override { 63 bool IsVisible() override {
64 return true; 64 return true;
65 } 65 }
66 virtual ActivityMediaState GetMediaState() override { 66 ActivityMediaState GetMediaState() override {
67 return Activity::ACTIVITY_MEDIA_STATE_NONE; 67 return Activity::ACTIVITY_MEDIA_STATE_NONE;
68 } 68 }
69 virtual aura::Window* GetWindow() override { 69 aura::Window* GetWindow() override {
70 return view_->GetWidget()->GetNativeWindow(); 70 return view_->GetWidget()->GetNativeWindow();
71 } 71 }
72 72
73 // ActivityViewModel: 73 // ActivityViewModel:
74 virtual void Init() override {} 74 void Init() override {}
75 virtual SkColor GetRepresentativeColor() const override { return 0; } 75 SkColor GetRepresentativeColor() const override { return 0; }
76 virtual base::string16 GetTitle() const override { return title_; } 76 base::string16 GetTitle() const override { return title_; }
77 virtual bool UsesFrame() const override { return true; } 77 bool UsesFrame() const override { return true; }
78 virtual views::View* GetContentsView() override { return view_; } 78 views::View* GetContentsView() override { return view_; }
79 virtual views::Widget* CreateWidget() override { return NULL; } 79 views::Widget* CreateWidget() override { return NULL; }
80 virtual gfx::ImageSkia GetOverviewModeImage() override { 80 gfx::ImageSkia GetOverviewModeImage() override {
81 return gfx::ImageSkia(); 81 return gfx::ImageSkia();
82 } 82 }
83 83
84 private: 84 private:
85 // If known the registry which holds all activities for the associated app. 85 // If known the registry which holds all activities for the associated app.
86 AppActivityRegistry* app_activity_registry_; 86 AppActivityRegistry* app_activity_registry_;
87 87
88 // The title of the activity. 88 // The title of the activity.
89 base::string16 title_; 89 base::string16 title_;
90 90
91 // Our view. 91 // Our view.
92 views::View* view_; 92 views::View* view_;
93 93
94 // The current state for this activity. 94 // The current state for this activity.
95 ActivityState current_state_; 95 ActivityState current_state_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(TestAppActivity); 97 DISALLOW_COPY_AND_ASSIGN(TestAppActivity);
98 }; 98 };
99 99
100 // An AppContentDelegateClass which we can query for call stats. 100 // An AppContentDelegateClass which we can query for call stats.
101 class TestExtensionsDelegate : public ExtensionsDelegate { 101 class TestExtensionsDelegate : public ExtensionsDelegate {
102 public: 102 public:
103 TestExtensionsDelegate() : unload_called_(0), restart_called_(0) {} 103 TestExtensionsDelegate() : unload_called_(0), restart_called_(0) {}
104 virtual ~TestExtensionsDelegate() {} 104 ~TestExtensionsDelegate() override {}
105 105
106 int unload_called() const { return unload_called_; } 106 int unload_called() const { return unload_called_; }
107 int restart_called() const { return restart_called_; } 107 int restart_called() const { return restart_called_; }
108 108
109 // ExtensionsDelegate: 109 // ExtensionsDelegate:
110 virtual content::BrowserContext* GetBrowserContext() const override { 110 content::BrowserContext* GetBrowserContext() const override {
111 return NULL; 111 return NULL;
112 } 112 }
113 virtual const extensions::ExtensionSet& GetInstalledExtensions() override { 113 const extensions::ExtensionSet& GetInstalledExtensions() override {
114 return extension_set_; 114 return extension_set_;
115 } 115 }
116 // Unload an application. Returns true when unloaded. 116 // Unload an application. Returns true when unloaded.
117 virtual bool UnloadApp(const std::string& app_id) override { 117 bool UnloadApp(const std::string& app_id) override {
118 unload_called_++; 118 unload_called_++;
119 // Since we did not close anything we let the framework clean up. 119 // Since we did not close anything we let the framework clean up.
120 return false; 120 return false;
121 } 121 }
122 // Restarts an application. Returns true when the restart was initiated. 122 // Restarts an application. Returns true when the restart was initiated.
123 virtual bool LaunchApp(const std::string& app_id) override { 123 bool LaunchApp(const std::string& app_id) override {
124 restart_called_++; 124 restart_called_++;
125 return true; 125 return true;
126 } 126 }
127 virtual scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() 127 scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI()
128 override { 128 override {
129 return scoped_ptr<extensions::ExtensionInstallUI>(); 129 return scoped_ptr<extensions::ExtensionInstallUI>();
130 } 130 }
131 131
132 private: 132 private:
133 int unload_called_; 133 int unload_called_;
134 int restart_called_; 134 int restart_called_;
135 135
136 extensions::ExtensionSet extension_set_; 136 extensions::ExtensionSet extension_set_;
137 137
138 DISALLOW_COPY_AND_ASSIGN(TestExtensionsDelegate); 138 DISALLOW_COPY_AND_ASSIGN(TestExtensionsDelegate);
139 }; 139 };
140 140
141 } // namespace 141 } // namespace
142 142
143 // Our testing base. 143 // Our testing base.
144 class AppActivityTest : public AthenaTestBase { 144 class AppActivityTest : public AthenaTestBase {
145 public: 145 public:
146 AppActivityTest() : test_extensions_delegate_(NULL) {} 146 AppActivityTest() : test_extensions_delegate_(NULL) {}
147 virtual ~AppActivityTest() {} 147 ~AppActivityTest() override {}
148 148
149 // AthenaTestBase: 149 // AthenaTestBase:
150 virtual void SetUp() override { 150 void SetUp() override {
151 AthenaTestBase::SetUp(); 151 AthenaTestBase::SetUp();
152 // Create and install our TestAppContentDelegate with instrumentation. 152 // Create and install our TestAppContentDelegate with instrumentation.
153 ExtensionsDelegate::Shutdown(); 153 ExtensionsDelegate::Shutdown();
154 // The instance will be deleted by ExtensionsDelegate::Shutdown(). 154 // The instance will be deleted by ExtensionsDelegate::Shutdown().
155 test_extensions_delegate_ = new TestExtensionsDelegate(); 155 test_extensions_delegate_ = new TestExtensionsDelegate();
156 } 156 }
157 157
158 // A function to create an Activity. 158 // A function to create an Activity.
159 TestAppActivity* CreateAppActivity(const std::string& app_id) { 159 TestAppActivity* CreateAppActivity(const std::string& app_id) {
160 TestAppActivity* activity = new TestAppActivity(app_id); 160 TestAppActivity* activity = new TestAppActivity(app_id);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // However - the restart in this test framework does not really restart and 431 // However - the restart in this test framework does not really restart and
432 // all objects should be still there.. 432 // all objects should be still there..
433 EXPECT_EQ(1, AppRegistry::Get()->NumberOfApplications()); 433 EXPECT_EQ(1, AppRegistry::Get()->NumberOfApplications());
434 EXPECT_TRUE(app_activity_registry->unloaded_activity_proxy()); 434 EXPECT_TRUE(app_activity_registry->unloaded_activity_proxy());
435 Activity::Delete(app_activity_registry->unloaded_activity_proxy()); 435 Activity::Delete(app_activity_registry->unloaded_activity_proxy());
436 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications()); 436 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
437 } 437 }
438 438
439 } // namespace test 439 } // namespace test
440 } // namespace athena 440 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698