| Index: athena/content/app_activity_unittest.cc
|
| diff --git a/athena/content/app_activity_unittest.cc b/athena/content/app_activity_unittest.cc
|
| index 266b940fd4e9ae817b4d98feb64ffd8aec80c50a..56e9d41de85f3e37b38e98ad82863307bd3da5a3 100644
|
| --- a/athena/content/app_activity_unittest.cc
|
| +++ b/athena/content/app_activity_unittest.cc
|
| @@ -34,57 +34,22 @@ class TestAppActivity : public AppActivity {
|
| public:
|
| explicit TestAppActivity(const std::string& app_id)
|
| : AppActivity(app_id),
|
| - view_(new views::View()),
|
| - current_state_(ACTIVITY_VISIBLE) {
|
| - app_activity_registry_ =
|
| - AppRegistry::Get()->GetAppActivityRegistry(app_id, nullptr);
|
| - app_activity_registry_->RegisterAppActivity(this);
|
| + view_(new views::View()) {
|
| }
|
| ~TestAppActivity() override {
|
| - app_activity_registry_->UnregisterAppActivity(this);
|
| }
|
|
|
| AppActivityRegistry* app_activity_registry() {
|
| - return app_activity_registry_;
|
| - }
|
| -
|
| - // Activity:
|
| - ActivityViewModel* GetActivityViewModel() override { return this; }
|
| - void SetCurrentState(Activity::ActivityState state) override {
|
| - current_state_ = state;
|
| - if (state == ACTIVITY_UNLOADED)
|
| - app_activity_registry_->Unload();
|
| - }
|
| - ActivityState GetCurrentState() override { return current_state_; }
|
| - bool IsVisible() override { return true; }
|
| - ActivityMediaState GetMediaState() override {
|
| - return Activity::ACTIVITY_MEDIA_STATE_NONE;
|
| - }
|
| - aura::Window* GetWindow() override {
|
| - return view_->GetWidget() ? view_->GetWidget()->GetNativeWindow() : nullptr;
|
| + return AppActivity::app_activity_registry();
|
| }
|
|
|
| // ActivityViewModel:
|
| - void Init() override {}
|
| - SkColor GetRepresentativeColor() const override { return 0; }
|
| - base::string16 GetTitle() const override { return title_; }
|
| - bool UsesFrame() const override { return true; }
|
| views::View* GetContentsView() override { return view_; }
|
| - gfx::ImageSkia GetOverviewModeImage() override { return gfx::ImageSkia(); }
|
|
|
| private:
|
| - // If known the registry which holds all activities for the associated app.
|
| - AppActivityRegistry* app_activity_registry_;
|
| -
|
| - // The title of the activity.
|
| - base::string16 title_;
|
| -
|
| // Our view.
|
| views::View* view_;
|
|
|
| - // The current state for this activity.
|
| - ActivityState current_state_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(TestAppActivity);
|
| };
|
|
|
| @@ -149,6 +114,7 @@ class AppActivityTest : public AthenaTestBase {
|
| // A function to create an Activity.
|
| TestAppActivity* CreateAppActivity(const std::string& app_id) {
|
| TestAppActivity* activity = new TestAppActivity(app_id);
|
| + activity->SetCurrentState(Activity::ACTIVITY_VISIBLE);
|
| ActivityManager::Get()->AddActivity(activity);
|
| return activity;
|
| }
|
| @@ -158,16 +124,15 @@ class AppActivityTest : public AthenaTestBase {
|
| RunAllPendingInMessageLoop();
|
| }
|
|
|
| - // Get the position of the activity in the navigation history.
|
| + // Get the position of the activity in the navigation history (the position
|
| + // of the oldest activity is 0).
|
| int GetActivityPosition(Activity* activity) {
|
| - aura::Window* window = activity->GetActivityViewModel()->GetContentsView()
|
| - ->GetWidget()->GetNativeWindow();
|
| - aura::Window::Windows windows = activity->GetWindow()->parent()->children();
|
| - for (size_t i = 0; i < windows.size(); i++) {
|
| - if (windows[i] == window)
|
| - return i;
|
| - }
|
| - return -1;
|
| + const ActivityList& activity_list =
|
| + ActivityManager::Get()->GetActivityList();
|
| + ActivityList::const_iterator iter =
|
| + std::find(activity_list.begin(), activity_list.end(), activity);
|
| + return (iter == activity_list.end()) ? -1
|
| + : (activity_list.end() - iter - 1);
|
| }
|
|
|
| // To avoid interference of the ResourceManager in these AppActivity
|
|
|