OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "components/dom_distiller/content/distiller_page_web_contents.h" | 10 #include "components/dom_distiller/content/distiller_page_web_contents.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 optional_web_contents_handle.Pass()), | 157 optional_web_contents_handle.Pass()), |
158 expect_new_web_contents_(expect_new_web_contents), | 158 expect_new_web_contents_(expect_new_web_contents), |
159 new_web_contents_created_(false) {} | 159 new_web_contents_created_(false) {} |
160 | 160 |
161 void CreateNewWebContents(const GURL& url) override { | 161 void CreateNewWebContents(const GURL& url) override { |
162 ASSERT_EQ(true, expect_new_web_contents_); | 162 ASSERT_EQ(true, expect_new_web_contents_); |
163 new_web_contents_created_ = true; | 163 new_web_contents_created_ = true; |
164 // DistillerPageWebContents::CreateNewWebContents resets the scoped_ptr to | 164 // DistillerPageWebContents::CreateNewWebContents resets the scoped_ptr to |
165 // the WebContents, so intentionally leak WebContents here, since it is | 165 // the WebContents, so intentionally leak WebContents here, since it is |
166 // owned by the shell. | 166 // owned by the shell. |
167 content::WebContents* web_contents = web_contents_.release(); | 167 content::WebContents* web_contents = |
| 168 web_contents_handle_.release()->GetWebContents(); |
168 web_contents->GetLastCommittedURL(); | 169 web_contents->GetLastCommittedURL(); |
169 DistillerPageWebContents::CreateNewWebContents(url); | 170 DistillerPageWebContents::CreateNewWebContents(url); |
170 } | 171 } |
171 | 172 |
172 ~TestDistillerPageWebContents() override { | 173 ~TestDistillerPageWebContents() override { |
173 if (!expect_new_web_contents_) { | 174 if (!expect_new_web_contents_) { |
174 // Intentionally leaking WebContents, since it is owned by the shell. | 175 // Intentionally leaking WebContents, since it is owned by the shell. |
175 content::WebContents* web_contents = web_contents_.release(); | 176 content::WebContents* web_contents = |
| 177 web_contents_handle_.release()->GetWebContents(); |
176 web_contents->GetLastCommittedURL(); | 178 web_contents->GetLastCommittedURL(); |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 bool new_web_contents_created() { return new_web_contents_created_; } | 182 bool new_web_contents_created() { return new_web_contents_created_; } |
181 | 183 |
182 private: | 184 private: |
183 bool expect_new_web_contents_; | 185 bool expect_new_web_contents_; |
184 bool new_web_contents_created_; | 186 bool new_web_contents_created_; |
185 }; | 187 }; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 ASSERT_TRUE(js_result_); | 520 ASSERT_TRUE(js_result_); |
519 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); | 521 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); |
520 | 522 |
521 ASSERT_TRUE(dict->HasKey("success")); | 523 ASSERT_TRUE(dict->HasKey("success")); |
522 bool success; | 524 bool success; |
523 ASSERT_TRUE(dict->GetBoolean("success", &success)); | 525 ASSERT_TRUE(dict->GetBoolean("success", &success)); |
524 EXPECT_TRUE(success); | 526 EXPECT_TRUE(success); |
525 } | 527 } |
526 | 528 |
527 } // namespace dom_distiller | 529 } // namespace dom_distiller |
OLD | NEW |