| 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/test/chrome/athena_browsertest.h" | 6 #include "athena/test/chrome/athena_browsertest.h" |
| 7 #include "athena/test/chrome/test_util.h" | 7 #include "athena/test/chrome/test_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/tab_helper.h" | 9 #include "chrome/browser/extensions/tab_helper.h" |
| 10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Checks that the web activity helpers are created prior to the RenderView | 21 // Checks that the web activity helpers are created prior to the RenderView |
| 22 // being created. | 22 // being created. |
| 23 class HelpersCreatedChecker : public content::NotificationObserver { | 23 class HelpersCreatedChecker : public content::NotificationObserver { |
| 24 public: | 24 public: |
| 25 HelpersCreatedChecker() : helpers_created_prior_to_render_view_(true) { | 25 HelpersCreatedChecker() : helpers_created_prior_to_render_view_(true) { |
| 26 registrar_.Add(this, | 26 registrar_.Add(this, |
| 27 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 27 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 28 content::NotificationService::AllSources()); | 28 content::NotificationService::AllSources()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual ~HelpersCreatedChecker() { | 31 ~HelpersCreatedChecker() override { |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Returns true if WebActivity helpers were attached to the WebContents prior | 34 // Returns true if WebActivity helpers were attached to the WebContents prior |
| 35 // to the RenderView being created for the WebContents. | 35 // to the RenderView being created for the WebContents. |
| 36 bool HelpersCreatedPriorToRenderView() const { | 36 bool HelpersCreatedPriorToRenderView() const { |
| 37 return helpers_created_prior_to_render_view_; | 37 return helpers_created_prior_to_render_view_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // content::NotificationObserver: | 41 // content::NotificationObserver: |
| 42 virtual void Observe(int type, | 42 void Observe(int type, |
| 43 const content::NotificationSource& source, | 43 const content::NotificationSource& source, |
| 44 const content::NotificationDetails& details) override { | 44 const content::NotificationDetails& details) override { |
| 45 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 45 DCHECK_EQ(content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 46 type); | 46 type); |
| 47 | 47 |
| 48 // Assume that all of the WebActivity helpers were created if the | 48 // Assume that all of the WebActivity helpers were created if the |
| 49 // extensions::TabHelper was created. | 49 // extensions::TabHelper was created. |
| 50 content::WebContents* web_contents = | 50 content::WebContents* web_contents = |
| 51 content::Source<content::WebContents>(source).ptr(); | 51 content::Source<content::WebContents>(source).ptr(); |
| 52 helpers_created_prior_to_render_view_ &= | 52 helpers_created_prior_to_render_view_ &= |
| (...skipping 30 matching lines...) Expand all Loading... |
| 83 activity->SetCurrentState(Activity::ACTIVITY_UNLOADED); | 83 activity->SetCurrentState(Activity::ACTIVITY_UNLOADED); |
| 84 activity->SetCurrentState(Activity::ACTIVITY_VISIBLE); | 84 activity->SetCurrentState(Activity::ACTIVITY_VISIBLE); |
| 85 | 85 |
| 86 content::WebContents* web_contents2 = activity->GetWebContents(); | 86 content::WebContents* web_contents2 = activity->GetWebContents(); |
| 87 EXPECT_NE(web_contents1, web_contents2); | 87 EXPECT_NE(web_contents1, web_contents2); |
| 88 EXPECT_TRUE(web_contents2->GetRenderViewHost()->IsRenderViewLive()); | 88 EXPECT_TRUE(web_contents2->GetRenderViewHost()->IsRenderViewLive()); |
| 89 EXPECT_TRUE(checker.HelpersCreatedPriorToRenderView()); | 89 EXPECT_TRUE(checker.HelpersCreatedPriorToRenderView()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace athena | 92 } // namespace athena |
| OLD | NEW |