Remove `DeviceBase::ForceSetToggleForTesting`

This patch removes the function `DeviceBase::ForceSetToggleForTesting`
which was only used by Mock tests.

Bug: chromium:42240655
Test: dawn_unittests
Change-Id: Icf7cc7fb495dd6701266011f74528ac0ae6ed7e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/202278
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp
index fe4b757..84e96ed 100644
--- a/src/dawn/native/Device.cpp
+++ b/src/dawn/native/Device.cpp
@@ -2444,10 +2444,6 @@
     return mToggles;
 }
 
-void DeviceBase::ForceSetToggleForTesting(Toggle toggle, bool isEnabled) {
-    mToggles.ForceSet(toggle, isEnabled);
-}
-
 void DeviceBase::ForceEnableFeatureForTesting(Feature feature) {
     mEnabledFeatures.EnableFeature(feature);
     mFormatTable = BuildFormatTable(this);
diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h
index 1c5122c..cea3471 100644
--- a/src/dawn/native/Device.h
+++ b/src/dawn/native/Device.h
@@ -465,7 +465,6 @@
     // Constructor used only for mocking and testing.
     DeviceBase();
 
-    void ForceSetToggleForTesting(Toggle toggle, bool isEnabled);
     void ForceEnableFeatureForTesting(Feature feature);
 
     MaybeError Initialize(Ref<QueueBase> defaultQueue);
diff --git a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp
index 2a75326..ca76375 100644
--- a/src/dawn/tests/unittests/native/AllowedErrorTests.cpp
+++ b/src/dawn/tests/unittests/native/AllowedErrorTests.cpp
@@ -76,15 +76,16 @@
 
 class AllowedErrorTests : public DawnMockTest {
   public:
-    AllowedErrorTests() : DawnMockTest() {
+    ~AllowedErrorTests() override { DropDevice(); }
+
+  protected:
+    void SetUp() override {
+        DawnMockTest::SetUp();
         device.SetDeviceLostCallback(mDeviceLostCb.Callback(), mDeviceLostCb.MakeUserdata(this));
         device.SetUncapturedErrorCallback(mDeviceErrorCb.Callback(),
                                           mDeviceErrorCb.MakeUserdata(this));
     }
 
-    ~AllowedErrorTests() override { DropDevice(); }
-
-  protected:
     // Device mock callbacks used throughout the tests.
     StrictMock<MockCallback<wgpu::DeviceLostCallback>> mDeviceLostCb;
     StrictMock<MockCallback<wgpu::ErrorCallback>> mDeviceErrorCb;
diff --git a/src/dawn/tests/unittests/native/DestroyObjectTests.cpp b/src/dawn/tests/unittests/native/DestroyObjectTests.cpp
index a024878..0a48fa0 100644
--- a/src/dawn/tests/unittests/native/DestroyObjectTests.cpp
+++ b/src/dawn/tests/unittests/native/DestroyObjectTests.cpp
@@ -103,7 +103,7 @@
   public:
     DestroyObjectTests() : DawnMockTest() {
         // Skipping validation on descriptors as coverage for validation is already present.
-        mDeviceMock->ForceSetToggleForTesting(Toggle::SkipValidation, true);
+        mDeviceToggles.ForceSet(Toggle::SkipValidation, true);
     }
 };
 
diff --git a/src/dawn/tests/unittests/native/mocks/DawnMockTest.cpp b/src/dawn/tests/unittests/native/mocks/DawnMockTest.cpp
index 1df3aeb..410f719 100644
--- a/src/dawn/tests/unittests/native/mocks/DawnMockTest.cpp
+++ b/src/dawn/tests/unittests/native/mocks/DawnMockTest.cpp
@@ -34,24 +34,23 @@
 
 namespace dawn::native {
 
-DawnMockTest::DawnMockTest() {
-    dawnProcSetProcs(&dawn::native::GetProcs());
+DawnMockTest::DawnMockTest() : mDeviceToggles(ToggleStage::Device) {}
 
+void DawnMockTest::SetUp() {
+    dawnProcSetProcs(&dawn::native::GetProcs());
     Ref<InstanceBase> instance = APICreateInstance(nullptr);
     const auto& adapters = instance->EnumerateAdapters();
     DAWN_ASSERT(!adapters.empty());
 
-    DeviceDescriptor deviceDescriptor = {};
-    auto result = ValidateAndUnpack(&deviceDescriptor);
+    auto result = ValidateAndUnpack(&mDeviceDescriptor);
     DAWN_ASSERT(result.IsSuccess());
     UnpackedPtr<DeviceDescriptor> packedDeviceDescriptor = result.AcquireSuccess();
 
     Ref<DeviceBase::DeviceLostEvent> lostEvent =
-        DeviceBase::DeviceLostEvent::Create(&deviceDescriptor);
-    TogglesState deviceToggles(ToggleStage::Device);
+        DeviceBase::DeviceLostEvent::Create(&mDeviceDescriptor);
 
     auto deviceMock = AcquireRef(new ::testing::NiceMock<DeviceMock>(
-        adapters[0].Get(), packedDeviceDescriptor, deviceToggles, std::move(lostEvent)));
+        adapters[0].Get(), packedDeviceDescriptor, mDeviceToggles, std::move(lostEvent)));
     mDeviceMock = deviceMock.Get();
     device = wgpu::Device::Acquire(ToAPI(ReturnToAPI<DeviceBase>(std::move(deviceMock))));
 }
diff --git a/src/dawn/tests/unittests/native/mocks/DawnMockTest.h b/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
index e5ffdb0..c02548c 100644
--- a/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
+++ b/src/dawn/tests/unittests/native/mocks/DawnMockTest.h
@@ -41,8 +41,11 @@
     void ProcessEvents();
 
   protected:
+    void SetUp() override;
     void DropDevice();
 
+    DeviceDescriptor mDeviceDescriptor;
+    TogglesState mDeviceToggles;
     raw_ptr<::testing::NiceMock<DeviceMock>> mDeviceMock;
     wgpu::Device device;
 };
diff --git a/src/dawn/tests/unittests/native/mocks/DeviceMock.h b/src/dawn/tests/unittests/native/mocks/DeviceMock.h
index e36429a..47ba449 100644
--- a/src/dawn/tests/unittests/native/mocks/DeviceMock.h
+++ b/src/dawn/tests/unittests/native/mocks/DeviceMock.h
@@ -47,11 +47,8 @@
     // Exposes some protected functions for testing purposes.
     using DeviceBase::DestroyObjects;
     using DeviceBase::ForceEnableFeatureForTesting;
-    using DeviceBase::ForceSetToggleForTesting;
 
-    // TODO(chromium:42240655):
-    // 1. Implement AdapterMock and use it in the constructor of DeviceMock
-    // 2. Remove ForceSetToggleForTesting calls
+    // TODO(chromium:42240655): Implement AdapterMock and use it in the constructor of DeviceMock
     DeviceMock(AdapterBase* adapter,
                const UnpackedPtr<DeviceDescriptor>& descriptor,
                const TogglesState& deviceToggles,