Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / install_verification / win / loaded_modules_snapshot_unittest.cc
blob0d716f4aa729460c43733240c0a8ed170b5580a4
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/install_verification/win/loaded_modules_snapshot.h"
7 #include <Windows.h>
9 #include <algorithm>
10 #include <vector>
12 #include "base/bind.h"
13 #include "base/callback_helpers.h"
14 #include "chrome/browser/install_verification/win/module_verification_test.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 TEST(LoadedModulesSnapshotTest, TestCase) {
18 std::vector<HMODULE> snapshot;
20 ASSERT_TRUE(GetLoadedModulesSnapshot(&snapshot));
21 size_t original_snapshot_size = snapshot.size();
22 ASSERT_GT(original_snapshot_size, 0u);
23 snapshot.clear();
25 // Load in a new module. Pick msvidc32.dll as it is present from WinXP to
26 // Win8 and yet rarely used.
27 ASSERT_EQ(NULL, ::GetModuleHandle(L"msvidc32.dll"));
29 HMODULE new_dll = ::LoadLibrary(L"msvidc32.dll");
30 ASSERT_NE(static_cast<HMODULE>(NULL), new_dll);
31 base::ScopedClosureRunner release_new_dll(
32 base::Bind(base::IgnoreResult(&::FreeLibrary), new_dll));
33 ASSERT_TRUE(GetLoadedModulesSnapshot(&snapshot));
34 ASSERT_GT(snapshot.size(), original_snapshot_size);
35 ASSERT_NE(snapshot.end(),
36 std::find(snapshot.begin(), snapshot.end(), new_dll));