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

Side by Side Diff: third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp

Issue 2831843002: Revert of Worker: Introduce per-global-scope task scheduler (Closed)
Patch Set: Created 3 years, 8 months 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
OLDNEW
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 <memory>
6 #include "core/dom/TaskRunnerHelper.h"
7 #include "core/events/MessageEvent.h" 5 #include "core/events/MessageEvent.h"
8 #include "core/inspector/ConsoleMessageStorage.h" 6 #include "core/inspector/ConsoleMessageStorage.h"
9 #include "core/testing/DummyPageHolder.h" 7 #include "core/testing/DummyPageHolder.h"
10 #include "core/workers/DedicatedWorkerGlobalScope.h" 8 #include "core/workers/DedicatedWorkerGlobalScope.h"
11 #include "core/workers/DedicatedWorkerThread.h" 9 #include "core/workers/DedicatedWorkerThread.h"
12 #include "core/workers/InProcessWorkerMessagingProxy.h" 10 #include "core/workers/InProcessWorkerMessagingProxy.h"
13 #include "core/workers/InProcessWorkerObjectProxy.h" 11 #include "core/workers/InProcessWorkerObjectProxy.h"
14 #include "core/workers/WorkerInspectorProxy.h" 12 #include "core/workers/WorkerInspectorProxy.h"
15 #include "core/workers/WorkerThread.h" 13 #include "core/workers/WorkerThread.h"
16 #include "core/workers/WorkerThreadStartupData.h" 14 #include "core/workers/WorkerThreadStartupData.h"
17 #include "core/workers/WorkerThreadTestHelper.h" 15 #include "core/workers/WorkerThreadTestHelper.h"
18 #include "platform/CrossThreadFunctional.h" 16 #include "platform/CrossThreadFunctional.h"
19 #include "platform/testing/UnitTestHelpers.h" 17 #include "platform/testing/UnitTestHelpers.h"
20 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include <memory>
22 21
23 namespace blink { 22 namespace blink {
24 23
25 namespace { 24 namespace {
26 25
27 // These are chosen by trial-and-error. Making these intervals smaller causes 26 // These are chosen by trial-and-error. Making these intervals smaller causes
28 // test flakiness. The main thread needs to wait until message confirmation and 27 // test flakiness. The main thread needs to wait until message confirmation and
29 // activity report separately. If the intervals are very short, they are 28 // activity report separately. If the intervals are very short, they are
30 // notified to the main thread almost at the same time and the thread may miss 29 // notified to the main thread almost at the same time and the thread may miss
31 // the second notification. 30 // the second notification.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 TEST_F(DedicatedWorkerTest, UseCounter) { 381 TEST_F(DedicatedWorkerTest, UseCounter) {
383 const String source_code = "// Do nothing"; 382 const String source_code = "// Do nothing";
384 WorkerMessagingProxy()->StartWithSourceCode(source_code); 383 WorkerMessagingProxy()->StartWithSourceCode(source_code);
385 384
386 // This feature is randomly selected. 385 // This feature is randomly selected.
387 const UseCounter::Feature kFeature1 = UseCounter::Feature::kRequestFileSystem; 386 const UseCounter::Feature kFeature1 = UseCounter::Feature::kRequestFileSystem;
388 387
389 // API use on the DedicatedWorkerGlobalScope should be recorded in UseCounter 388 // API use on the DedicatedWorkerGlobalScope should be recorded in UseCounter
390 // on the Document. 389 // on the Document.
391 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature1)); 390 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature1));
392 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) 391 GetWorkerThread()->PostTask(
393 ->PostTask( 392 BLINK_FROM_HERE,
394 BLINK_FROM_HERE, 393 CrossThreadBind(&DedicatedWorkerThreadForTest::CountFeature,
395 CrossThreadBind(&DedicatedWorkerThreadForTest::CountFeature, 394 CrossThreadUnretained(GetWorkerThread()), kFeature1));
396 CrossThreadUnretained(GetWorkerThread()), kFeature1));
397 testing::EnterRunLoop(); 395 testing::EnterRunLoop();
398 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1)); 396 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1));
399 397
400 // This feature is randomly selected from Deprecation::deprecationMessage(). 398 // This feature is randomly selected from Deprecation::deprecationMessage().
401 const UseCounter::Feature kFeature2 = 399 const UseCounter::Feature kFeature2 =
402 UseCounter::Feature::kPrefixedStorageInfo; 400 UseCounter::Feature::kPrefixedStorageInfo;
403 401
404 // Deprecated API use on the DedicatedWorkerGlobalScope should be recorded in 402 // Deprecated API use on the DedicatedWorkerGlobalScope should be recorded in
405 // UseCounter on the Document. 403 // UseCounter on the Document.
406 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2)); 404 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2));
407 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) 405 GetWorkerThread()->PostTask(
408 ->PostTask( 406 BLINK_FROM_HERE,
409 BLINK_FROM_HERE, 407 CrossThreadBind(&DedicatedWorkerThreadForTest::CountDeprecation,
410 CrossThreadBind(&DedicatedWorkerThreadForTest::CountDeprecation, 408 CrossThreadUnretained(GetWorkerThread()), kFeature2));
411 CrossThreadUnretained(GetWorkerThread()), kFeature2));
412 testing::EnterRunLoop(); 409 testing::EnterRunLoop();
413 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); 410 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2));
414 } 411 }
415 412
416 } // namespace blink 413 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698