+TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
+ ScopedGpuDataManagerImpl manager;
+
+ const std::string blacklist_json = LONG_STRING_CONST(
+ {
+ "name": "gpu blacklist",
+ "version": "0.1",
+ "entries": [
+ {
+ "id": 1,
+ "vendor_id": "0x8086",
+ "multi_gpu_category": "active",
+ "features": [
+ "webgl"
+ ]
+ }
+ ]
+ }
+ );
+
+ // Two GPUs, the secondary Intel GPU is active.
+ gpu::GPUInfo gpu_info;
+ gpu_info.gpu.vendor_id = 0x10de;
+ gpu_info.gpu.device_id = 0x0640;
+ gpu_info.gpu.active = false;
+ gpu::GPUInfo::GPUDevice intel_gpu;
+ intel_gpu.vendor_id = 0x8086;
+ intel_gpu.device_id = 0x04a1;
+ intel_gpu.active = true;
+ gpu_info.secondary_gpus.push_back(intel_gpu);
+
+ manager->InitializeForTesting(blacklist_json, gpu_info);
+ TestObserver observer;
+ manager->AddObserver(&observer);
+
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+
+ // Update with the same Intel GPU active.
+ EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1));
+ {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+ EXPECT_FALSE(observer.gpu_info_updated());
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+
+ // Set NVIDIA GPU to be active.
+ EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640));
+ {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+ EXPECT_TRUE(observer.gpu_info_updated());
+ EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+
+ observer.Reset();
+ EXPECT_FALSE(observer.gpu_info_updated());
+
+ // Update with the same NVIDIA GPU active.
+ EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640));
+ {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+ EXPECT_FALSE(observer.gpu_info_updated());
+ EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+
+ // Set Intel GPU to be active.
+ EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1));
+ {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+ EXPECT_TRUE(observer.gpu_info_updated());
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+}
+