OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" | 5 #include "chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/strings/nullable_string16.h" | 16 #include "base/strings/nullable_string16.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chrome/browser/installable/installable_manager.h" | 20 #include "chrome/browser/installable/installable_manager.h" |
21 #include "chrome/common/web_application_info.h" | 21 #include "chrome/common/web_application_info.h" |
22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
24 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 24 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
25 #include "content/browser/service_worker/service_worker_context_core.h" | 25 #include "content/browser/service_worker/service_worker_context_core.h" |
dominickn
2017/07/07 03:04:32
Nit: #include "content/common/service_worker/servi
yuryu
2017/07/10 03:38:10
Done.
| |
26 #include "content/common/service_worker/service_worker_status_code.h" | 26 #include "content/common/service_worker/service_worker_status_code.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/site_instance.h" | 28 #include "content/public/browser/site_instance.h" |
29 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
30 #include "content/public/common/manifest.h" | 30 #include "content/public/common/manifest.h" |
31 #include "content/test/test_web_contents.h" | 31 #include "content/test/test_web_contents.h" |
32 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
33 #include "third_party/WebKit/public/platform/WebDisplayMode.h" | 33 #include "third_party/WebKit/public/platform/WebDisplayMode.h" |
34 #include "ui/gfx/image/image_unittest_util.h" | 34 #include "ui/gfx/image/image_unittest_util.h" |
35 #include "url/gurl.h" | 35 #include "url/gurl.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 MockWebContents* mock_web_contents = | 256 MockWebContents* mock_web_contents = |
257 static_cast<MockWebContents*>(web_contents()); | 257 static_cast<MockWebContents*>(web_contents()); |
258 mock_web_contents->SetShouldManifestTimeOut(should_time_out); | 258 mock_web_contents->SetShouldManifestTimeOut(should_time_out); |
259 } | 259 } |
260 | 260 |
261 // Registers service worker at |url|. Blocks till the service worker is | 261 // Registers service worker at |url|. Blocks till the service worker is |
262 // registered. | 262 // registered. |
263 void RegisterServiceWorker(const GURL& url) { | 263 void RegisterServiceWorker(const GURL& url) { |
264 base::RunLoop run_loop; | 264 base::RunLoop run_loop; |
265 embedded_worker_test_helper_->context()->RegisterServiceWorker( | 265 embedded_worker_test_helper_->context()->RegisterServiceWorker( |
266 url, GURL(url.spec() + "/service_worker.js"), nullptr, | 266 GURL(url.spec() + "/service_worker.js"), |
267 content::ServiceWorkerRegistrationOptions(url), nullptr, | |
267 base::Bind(&AddToHomescreenDataFetcherTest::OnServiceWorkerRegistered, | 268 base::Bind(&AddToHomescreenDataFetcherTest::OnServiceWorkerRegistered, |
268 base::Unretained(this), run_loop.QuitClosure())); | 269 base::Unretained(this), run_loop.QuitClosure())); |
269 } | 270 } |
270 | 271 |
271 private: | 272 private: |
272 // Callback for RegisterServiceWorker() for when service worker registration | 273 // Callback for RegisterServiceWorker() for when service worker registration |
273 // has completed. | 274 // has completed. |
274 void OnServiceWorkerRegistered(const base::Closure& callback, | 275 void OnServiceWorkerRegistered(const base::Closure& callback, |
275 content::ServiceWorkerStatusCode status, | 276 content::ServiceWorkerStatusCode status, |
276 const std::string& status_message, | 277 const std::string& status_message, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 EXPECT_TRUE(base::EqualsASCII(waiter.title(), kDefaultManifestShortName)); | 463 EXPECT_TRUE(base::EqualsASCII(waiter.title(), kDefaultManifestShortName)); |
463 EXPECT_TRUE(base::EqualsASCII(fetcher->shortcut_info().user_title, | 464 EXPECT_TRUE(base::EqualsASCII(fetcher->shortcut_info().user_title, |
464 kDefaultManifestShortName)); | 465 kDefaultManifestShortName)); |
465 | 466 |
466 fetcher->set_weak_observer(nullptr); | 467 fetcher->set_weak_observer(nullptr); |
467 } | 468 } |
468 | 469 |
469 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, | 470 INSTANTIATE_TEST_CASE_P(CheckWebApkCompatibility, |
470 AddToHomescreenDataFetcherTestCommon, | 471 AddToHomescreenDataFetcherTestCommon, |
471 ::testing::Values(false, true)); | 472 ::testing::Values(false, true)); |
OLD | NEW |