Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: content/browser/service_worker/service_worker_version_unittest.cc

Issue 2485053002: Fix a failing service worker startup test to work with mojo IPC (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 void OnStartWorker(int embedded_worker_id, 305 void OnStartWorker(int embedded_worker_id,
306 int64_t service_worker_version_id, 306 int64_t service_worker_version_id,
307 const GURL& scope, 307 const GURL& scope,
308 const GURL& script_url, 308 const GURL& script_url,
309 bool pause_after_download) override { 309 bool pause_after_download) override {
310 switch (mode_) { 310 switch (mode_) {
311 case StartMode::STALL: 311 case StartMode::STALL:
312 break; // Do nothing. 312 break; // Do nothing.
313 case StartMode::FAIL: 313 case StartMode::FAIL:
314 OnStopWorker(embedded_worker_id); 314 if (is_mojo_enabled_) {
315 ASSERT_EQ(current_mock_instance_index_ + 1,
316 mock_instance_clients()->size());
317 // Remove the connection by peer
318 mock_instance_clients()->at(current_mock_instance_index_).reset();
319 } else {
320 OnStopWorker(embedded_worker_id);
321 }
315 break; 322 break;
316 case StartMode::SUCCEED: 323 case StartMode::SUCCEED:
317 MessageReceiver::OnStartWorker(embedded_worker_id, 324 MessageReceiver::OnStartWorker(embedded_worker_id,
318 service_worker_version_id, scope, 325 service_worker_version_id, scope,
319 script_url, pause_after_download); 326 script_url, pause_after_download);
320 break; 327 break;
321 } 328 }
329 current_mock_instance_index_++;
322 } 330 }
323 331
324 void set_start_mode(StartMode mode) { mode_ = mode; } 332 void set_start_mode(StartMode mode) { mode_ = mode; }
333 void set_is_mojo_enabled(bool enabled) { is_mojo_enabled_ = enabled; }
325 334
326 private: 335 private:
336 bool is_mojo_enabled_;
337 uint32_t current_mock_instance_index_ = 0;
327 StartMode mode_ = StartMode::STALL; 338 StartMode mode_ = StartMode::STALL;
328 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStart); 339 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStart);
329 }; 340 };
330 341
331 class ServiceWorkerFailToStartTest : public ServiceWorkerVersionTestP { 342 class ServiceWorkerFailToStartTest : public ServiceWorkerVersionTestP {
332 protected: 343 protected:
333 ServiceWorkerFailToStartTest() : ServiceWorkerVersionTestP() {} 344 ServiceWorkerFailToStartTest() : ServiceWorkerVersionTestP() {}
334 345
335 void set_start_mode(MessageReceiverDisallowStart::StartMode mode) { 346 void set_start_mode(MessageReceiverDisallowStart::StartMode mode) {
336 MessageReceiverDisallowStart* helper = 347 MessageReceiverDisallowStart* helper =
337 static_cast<MessageReceiverDisallowStart*>(helper_.get()); 348 static_cast<MessageReceiverDisallowStart*>(helper_.get());
338 helper->set_start_mode(mode); 349 helper->set_start_mode(mode);
350 helper->set_is_mojo_enabled(is_mojo_enabled());
339 } 351 }
340 352
341 std::unique_ptr<MessageReceiver> GetMessageReceiver() override { 353 std::unique_ptr<MessageReceiver> GetMessageReceiver() override {
342 return base::MakeUnique<MessageReceiverDisallowStart>(); 354 return base::MakeUnique<MessageReceiverDisallowStart>();
horo 2016/11/08 07:30:12 You can set is_mojo_enabled in the constructor of
shimazu 2016/11/09 02:23:36 Done.
343 } 355 }
344 356
345 private: 357 private:
346 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFailToStartTest); 358 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFailToStartTest);
347 }; 359 };
348 360
349 class NoOpStopWorkerEmbeddedWorkerInstanceClient 361 class NoOpStopWorkerEmbeddedWorkerInstanceClient
350 : public EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient { 362 : public EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient {
351 public: 363 public:
352 explicit NoOpStopWorkerEmbeddedWorkerInstanceClient( 364 explicit NoOpStopWorkerEmbeddedWorkerInstanceClient(
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 ServiceWorkerNavigationHintUMATest, 1797 ServiceWorkerNavigationHintUMATest,
1786 testing::Bool()); 1798 testing::Bool());
1787 INSTANTIATE_TEST_CASE_P(ServiceWorkerStallInStoppingTest, 1799 INSTANTIATE_TEST_CASE_P(ServiceWorkerStallInStoppingTest,
1788 ServiceWorkerStallInStoppingTest, 1800 ServiceWorkerStallInStoppingTest,
1789 testing::Bool()); 1801 testing::Bool());
1790 INSTANTIATE_TEST_CASE_P(ServiceWorkerVersionWithMojoTest, 1802 INSTANTIATE_TEST_CASE_P(ServiceWorkerVersionWithMojoTest,
1791 ServiceWorkerVersionWithMojoTest, 1803 ServiceWorkerVersionWithMojoTest,
1792 testing::Bool()); 1804 testing::Bool());
1793 1805
1794 } // namespace content 1806 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698