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

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

Issue 653563004: NULL -> nullptr under 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
« no previous file with comments | « athena/content/app_activity_registry.cc ('k') | athena/content/app_registry_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 const char kDummyApp2[] = "bbbbbbb"; 30 const char kDummyApp2[] = "bbbbbbb";
31 31
32 // A dummy test app activity which works without content / ShellAppWindow. 32 // A dummy test app activity which works without content / ShellAppWindow.
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, nullptr);
41 app_activity_registry_->RegisterAppActivity(this); 41 app_activity_registry_->RegisterAppActivity(this);
42 } 42 }
43 virtual ~TestAppActivity() { 43 virtual ~TestAppActivity() {
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
(...skipping 18 matching lines...) Expand all
69 virtual aura::Window* GetWindow() override { 69 virtual 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 virtual void Init() override {}
75 virtual SkColor GetRepresentativeColor() const override { return 0; } 75 virtual SkColor GetRepresentativeColor() const override { return 0; }
76 virtual base::string16 GetTitle() const override { return title_; } 76 virtual base::string16 GetTitle() const override { return title_; }
77 virtual bool UsesFrame() const override { return true; } 77 virtual bool UsesFrame() const override { return true; }
78 virtual views::View* GetContentsView() override { return view_; } 78 virtual views::View* GetContentsView() override { return view_; }
79 virtual views::Widget* CreateWidget() override { return NULL; } 79 virtual views::Widget* CreateWidget() override { return nullptr; }
80 virtual gfx::ImageSkia GetOverviewModeImage() override { 80 virtual 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_;
(...skipping 11 matching lines...) Expand all
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 virtual ~TestExtensionsDelegate() {}
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 virtual content::BrowserContext* GetBrowserContext() const override {
111 return NULL; 111 return nullptr;
112 } 112 }
113 virtual const extensions::ExtensionSet& GetInstalledExtensions() override { 113 virtual 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 virtual 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 }
(...skipping 14 matching lines...) Expand all
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_(nullptr) {}
147 virtual ~AppActivityTest() {} 147 virtual ~AppActivityTest() {}
148 148
149 // AthenaTestBase: 149 // AthenaTestBase:
150 virtual void SetUp() override { 150 virtual 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 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 DISALLOW_COPY_AND_ASSIGN(AppActivityTest); 197 DISALLOW_COPY_AND_ASSIGN(AppActivityTest);
198 }; 198 };
199 199
200 // Only creates one activity and destroys it. 200 // Only creates one activity and destroys it.
201 TEST_F(AppActivityTest, OneAppActivity) { 201 TEST_F(AppActivityTest, OneAppActivity) {
202 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications()); 202 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
203 { 203 {
204 TestAppActivity* app_activity = CreateAppActivity(kDummyApp1); 204 TestAppActivity* app_activity = CreateAppActivity(kDummyApp1);
205 EXPECT_EQ(1, AppRegistry::Get()->NumberOfApplications()); 205 EXPECT_EQ(1, AppRegistry::Get()->NumberOfApplications());
206 EXPECT_EQ(1, app_activity->app_activity_registry()->NumberOfActivities()); 206 EXPECT_EQ(1, app_activity->app_activity_registry()->NumberOfActivities());
207 EXPECT_EQ(AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, NULL), 207 EXPECT_EQ(AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, nullptr),
208 app_activity->app_activity_registry()); 208 app_activity->app_activity_registry());
209 DeleteActivity(app_activity); 209 DeleteActivity(app_activity);
210 } 210 }
211 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications()); 211 EXPECT_EQ(0, AppRegistry::Get()->NumberOfApplications());
212 EXPECT_EQ(0, test_extensions_delegate()->unload_called()); 212 EXPECT_EQ(0, test_extensions_delegate()->unload_called());
213 EXPECT_EQ(0, test_extensions_delegate()->restart_called()); 213 EXPECT_EQ(0, test_extensions_delegate()->restart_called());
214 } 214 }
215 215
216 // Test running of two applications. 216 // Test running of two applications.
217 TEST_F(AppActivityTest, TwoAppsWithOneActivityEach) { 217 TEST_F(AppActivityTest, TwoAppsWithOneActivityEach) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // After setting our activity to unloaded however the application should get 290 // After setting our activity to unloaded however the application should get
291 // unloaded as requested. 291 // unloaded as requested.
292 app_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED); 292 app_activity->SetCurrentState(Activity::ACTIVITY_UNLOADED);
293 RunAllPendingInMessageLoop(); 293 RunAllPendingInMessageLoop();
294 EXPECT_EQ(1, test_extensions_delegate()->unload_called()); 294 EXPECT_EQ(1, test_extensions_delegate()->unload_called());
295 295
296 // Check that our created application is gone, and instead a proxy got 296 // Check that our created application is gone, and instead a proxy got
297 // created. 297 // created.
298 ASSERT_EQ(1, AppRegistry::Get()->NumberOfApplications()); 298 ASSERT_EQ(1, AppRegistry::Get()->NumberOfApplications());
299 ASSERT_EQ(app_activity_registry, 299 ASSERT_EQ(app_activity_registry,
300 AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, NULL)); 300 AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, nullptr));
301 EXPECT_EQ(0, app_activity_registry->NumberOfActivities()); 301 EXPECT_EQ(0, app_activity_registry->NumberOfActivities());
302 Activity* activity_proxy = app_activity_registry->unloaded_activity_proxy(); 302 Activity* activity_proxy = app_activity_registry->unloaded_activity_proxy();
303 ASSERT_TRUE(activity_proxy); 303 ASSERT_TRUE(activity_proxy);
304 EXPECT_NE(app_activity, activity_proxy); 304 EXPECT_NE(app_activity, activity_proxy);
305 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, activity_proxy->GetCurrentState()); 305 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, activity_proxy->GetCurrentState());
306 EXPECT_EQ(0, test_extensions_delegate()->restart_called()); 306 EXPECT_EQ(0, test_extensions_delegate()->restart_called());
307 307
308 // Close the proxy object and make sure that nothing bad happens. 308 // Close the proxy object and make sure that nothing bad happens.
309 DeleteActivity(activity_proxy); 309 DeleteActivity(activity_proxy);
310 310
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 app_activity2->SetCurrentState(Activity::ACTIVITY_UNLOADED); 380 app_activity2->SetCurrentState(Activity::ACTIVITY_UNLOADED);
381 RunAllPendingInMessageLoop(); 381 RunAllPendingInMessageLoop();
382 EXPECT_EQ(0, test_extensions_delegate()->unload_called()); 382 EXPECT_EQ(0, test_extensions_delegate()->unload_called());
383 app_activity3->SetCurrentState(Activity::ACTIVITY_UNLOADED); 383 app_activity3->SetCurrentState(Activity::ACTIVITY_UNLOADED);
384 RunAllPendingInMessageLoop(); 384 RunAllPendingInMessageLoop();
385 EXPECT_EQ(1, test_extensions_delegate()->unload_called()); 385 EXPECT_EQ(1, test_extensions_delegate()->unload_called());
386 386
387 // Now there should only be the proxy activity left. 387 // Now there should only be the proxy activity left.
388 ASSERT_EQ(1, AppRegistry::Get()->NumberOfApplications()); 388 ASSERT_EQ(1, AppRegistry::Get()->NumberOfApplications());
389 ASSERT_EQ(app_activity_registry, 389 ASSERT_EQ(app_activity_registry,
390 AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, NULL)); 390 AppRegistry::Get()->GetAppActivityRegistry(kDummyApp1, nullptr));
391 EXPECT_EQ(0, app_activity_registry->NumberOfActivities()); 391 EXPECT_EQ(0, app_activity_registry->NumberOfActivities());
392 Activity* activity_proxy = app_activity_registry->unloaded_activity_proxy(); 392 Activity* activity_proxy = app_activity_registry->unloaded_activity_proxy();
393 ASSERT_TRUE(activity_proxy); 393 ASSERT_TRUE(activity_proxy);
394 EXPECT_NE(app_activity1, activity_proxy); 394 EXPECT_NE(app_activity1, activity_proxy);
395 EXPECT_NE(app_activity2, activity_proxy); 395 EXPECT_NE(app_activity2, activity_proxy);
396 EXPECT_NE(app_activity3, activity_proxy); 396 EXPECT_NE(app_activity3, activity_proxy);
397 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, activity_proxy->GetCurrentState()); 397 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, activity_proxy->GetCurrentState());
398 398
399 // Close the proxy object and make sure that nothing bad happens. 399 // Close the proxy object and make sure that nothing bad happens.
400 DeleteActivity(activity_proxy); 400 DeleteActivity(activity_proxy);
(...skipping 30 matching lines...) Expand all
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
« no previous file with comments | « athena/content/app_activity_registry.cc ('k') | athena/content/app_registry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698