| 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 "athena/activity/public/activity.h" | 5 #include "athena/activity/public/activity.h" |
| 6 #include "athena/activity/public/activity_manager.h" | 6 #include "athena/activity/public/activity_manager.h" |
| 7 #include "athena/activity/public/activity_view_model.h" | 7 #include "athena/activity/public/activity_view_model.h" |
| 8 #include "athena/resource_manager/memory_pressure_notifier.h" | 8 #include "athena/resource_manager/memory_pressure_notifier.h" |
| 9 #include "athena/resource_manager/public/resource_manager.h" | 9 #include "athena/resource_manager/public/resource_manager.h" |
| 10 #include "athena/test/base/athena_test_base.h" | 10 #include "athena/test/base/athena_test_base.h" |
| 11 #include "athena/test/base/sample_activity.h" | 11 #include "athena/test/base/sample_activity.h" |
| 12 #include "athena/wm/public/window_manager.h" | 12 #include "athena/wm/public/window_manager.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 16 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 17 | 17 |
| 18 namespace athena { | 18 namespace athena { |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // A dummy test app activity which works without content / ShellAppWindow. | 23 // A dummy test app activity which works without content / ShellAppWindow. |
| 24 class TestActivity : public SampleActivity { | 24 class TestActivity : public SampleActivity { |
| 25 public: | 25 public: |
| 26 explicit TestActivity(const std::string& title) | 26 explicit TestActivity(const std::string& title) |
| 27 : SampleActivity(0, 0, base::UTF8ToUTF16(title)), | 27 : SampleActivity(0, 0, base::UTF8ToUTF16(title)), |
| 28 media_state_(ACTIVITY_MEDIA_STATE_NONE), | 28 media_state_(ACTIVITY_MEDIA_STATE_NONE), |
| 29 is_visible_(false) {} | 29 is_visible_(false) {} |
| 30 virtual ~TestActivity() {} | 30 ~TestActivity() override {} |
| 31 | 31 |
| 32 void set_media_state(ActivityMediaState media_state) { | 32 void set_media_state(ActivityMediaState media_state) { |
| 33 media_state_ = media_state; | 33 media_state_ = media_state; |
| 34 } | 34 } |
| 35 void set_visible(bool visible) { is_visible_ = visible; } | 35 void set_visible(bool visible) { is_visible_ = visible; } |
| 36 | 36 |
| 37 // Activity overrides: | 37 // Activity overrides: |
| 38 virtual bool IsVisible() override { return is_visible_; } | 38 virtual bool IsVisible() override { return is_visible_; } |
| 39 virtual ActivityMediaState GetMediaState() override { return media_state_; } | 39 virtual ActivityMediaState GetMediaState() override { return media_state_; } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // The current media state. | 42 // The current media state. |
| 43 ActivityMediaState media_state_; | 43 ActivityMediaState media_state_; |
| 44 | 44 |
| 45 // Returns if it is visible or not. | 45 // Returns if it is visible or not. |
| 46 bool is_visible_; | 46 bool is_visible_; |
| 47 | 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(TestActivity); | 48 DISALLOW_COPY_AND_ASSIGN(TestActivity); |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 // Our testing base. | 53 // Our testing base. |
| 54 class ResourceManagerTest : public AthenaTestBase { | 54 class ResourceManagerTest : public AthenaTestBase { |
| 55 public: | 55 public: |
| 56 ResourceManagerTest() {} | 56 ResourceManagerTest() {} |
| 57 virtual ~ResourceManagerTest() {} | 57 ~ResourceManagerTest() override {} |
| 58 | 58 |
| 59 virtual void SetUp() override { | 59 virtual void SetUp() override { |
| 60 AthenaTestBase::SetUp(); | 60 AthenaTestBase::SetUp(); |
| 61 // Override the delay to be instantaneous. | 61 // Override the delay to be instantaneous. |
| 62 ResourceManager::Get()->SetWaitTimeBetweenResourceManageCalls(0); | 62 ResourceManager::Get()->SetWaitTimeBetweenResourceManageCalls(0); |
| 63 } | 63 } |
| 64 virtual void TearDown() override { | 64 virtual void TearDown() override { |
| 65 while (!activity_list_.empty()) | 65 while (!activity_list_.empty()) |
| 66 DeleteActivity(activity_list_[0]); | 66 DeleteActivity(activity_list_[0]); |
| 67 AthenaTestBase::TearDown(); | 67 AthenaTestBase::TearDown(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 ResourceManager::Get()->SetMemoryPressureAndStopMonitoring( | 353 ResourceManager::Get()->SetMemoryPressureAndStopMonitoring( |
| 354 ResourceManager::MEMORY_PRESSURE_CRITICAL); | 354 ResourceManager::MEMORY_PRESSURE_CRITICAL); |
| 355 EXPECT_EQ(Activity::ACTIVITY_VISIBLE, app1->GetCurrentState()); | 355 EXPECT_EQ(Activity::ACTIVITY_VISIBLE, app1->GetCurrentState()); |
| 356 EXPECT_EQ(Activity::ACTIVITY_INVISIBLE, app2->GetCurrentState()); | 356 EXPECT_EQ(Activity::ACTIVITY_INVISIBLE, app2->GetCurrentState()); |
| 357 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, app3->GetCurrentState()); | 357 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, app3->GetCurrentState()); |
| 358 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, app4->GetCurrentState()); | 358 EXPECT_EQ(Activity::ACTIVITY_UNLOADED, app4->GetCurrentState()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace test | 361 } // namespace test |
| 362 } // namespace athena | 362 } // namespace athena |
| OLD | NEW |