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

Unified Diff: content/browser/service_worker/embedded_worker_instance_unittest.cc

Issue 294073009: Save running SW instance info, including its SiteInstance, into the ProcessManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test SortProcesses without doing all the work to Start an instance. Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/embedded_worker_instance_unittest.cc
diff --git a/content/browser/service_worker/embedded_worker_instance_unittest.cc b/content/browser/service_worker/embedded_worker_instance_unittest.cc
index 244b5f9344c77741486b7a449a67d0219a739d88..d14ccd22f253bad483961b2b4d0ca2f998c78c73 100644
--- a/content/browser/service_worker/embedded_worker_instance_unittest.cc
+++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc
@@ -12,6 +12,7 @@
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/common/service_worker/embedded_worker_messages.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -129,7 +130,7 @@ TEST_F(EmbeddedWorkerInstanceTest, InstanceDestroyedBeforeStartFinishes) {
ipc_sink()->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID));
}
-TEST_F(EmbeddedWorkerInstanceTest, ChooseProcess) {
+TEST_F(EmbeddedWorkerInstanceTest, SortProcesses) {
scoped_ptr<EmbeddedWorkerInstance> worker =
embedded_worker_registry()->CreateWorker();
EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status());
@@ -145,22 +146,22 @@ TEST_F(EmbeddedWorkerInstanceTest, ChooseProcess) {
helper_->SimulateAddProcessToWorker(embedded_worker_id, 3);
// Process 3 has the biggest # of references and it should be chosen.
- ServiceWorkerStatusCode status;
- base::RunLoop run_loop;
- worker->Start(
- 1L,
- GURL("http://example.com/*"),
- GURL("http://example.com/worker.js"),
- std::vector<int>(),
- base::Bind(&SaveStatusAndCall, &status, run_loop.QuitClosure()));
- run_loop.Run();
- EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status);
- EXPECT_EQ(EmbeddedWorkerInstance::STARTING, worker->status());
- EXPECT_EQ(3, worker->process_id());
-
- // Wait until started message is sent back.
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker->status());
+ EXPECT_THAT(worker->SortProcesses(std::vector<int>()),
+ testing::ElementsAre(3, 2, 1));
kinuko 2014/05/23 02:53:23 Neat, didn't know this notation.
+ EXPECT_EQ(-1, worker->process_id());
+
+ // Argument processes are added to the existing set, but only for a single
+ // call.
+ std::vector<int> registering_processes;
+ registering_processes.push_back(1);
+ registering_processes.push_back(1);
+ registering_processes.push_back(1);
+ registering_processes.push_back(4);
+ EXPECT_THAT(worker->SortProcesses(registering_processes),
+ testing::ElementsAre(1, 3, 2, 4));
+
+ EXPECT_THAT(worker->SortProcesses(std::vector<int>()),
+ testing::ElementsAre(3, 2, 1));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698