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

Unified Diff: chrome/install_static/install_modes_unittest.cc

Issue 2764963002: Move ProgID methods from BrowserDistribution into install_static. (Closed)
Patch Set: huangs comments Created 3 years, 9 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
« no previous file with comments | « chrome/install_static/install_constants.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/install_static/install_modes_unittest.cc
diff --git a/chrome/install_static/install_modes_unittest.cc b/chrome/install_static/install_modes_unittest.cc
index e4593633f434e36dc39274e5484e6e31715c6819..ad0506aa1986414f4bd098cb5391e4ef8216f492 100644
--- a/chrome/install_static/install_modes_unittest.cc
+++ b/chrome/install_static/install_modes_unittest.cc
@@ -4,17 +4,40 @@
#include "chrome/install_static/install_modes.h"
+#include <windows.h>
+
+#include <ctype.h>
+
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::Eq;
using ::testing::Gt;
+using ::testing::Le;
using ::testing::Ne;
+using ::testing::Not;
+using ::testing::ResultOf;
using ::testing::StrEq;
using ::testing::StrNe;
namespace install_static {
+namespace {
+
+// A matcher that returns true if |arg| contains a character that is neither
+// alpha-numeric nor a period.
+MATCHER(ContainsIllegalProgIdChar, "") {
+ const wchar_t* scan = arg;
+ wint_t c;
+ while ((c = *scan++) != 0) {
+ if (!iswalnum(c) && c != L'.')
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
TEST(InstallModes, VerifyModes) {
ASSERT_THAT(NUM_INSTALL_MODES, Gt(0));
for (int i = 0; i < NUM_INSTALL_MODES; ++i) {
@@ -47,6 +70,17 @@ TEST(InstallModes, VerifyModes) {
else
ASSERT_THAT(mode.app_guid, StrEq(L""));
+ // The ProgID prefix must not be empty, must be no greater than 11
+ // characters long, must contain no punctuation, and may not start with a
+ // digit (https://msdn.microsoft.com/library/windows/desktop/dd542719.aspx).
+ ASSERT_THAT(mode.prog_id_prefix, StrNe(L""));
+ ASSERT_THAT(lstrlen(mode.prog_id_prefix), Le(11));
+ ASSERT_THAT(mode.prog_id_prefix, Not(ContainsIllegalProgIdChar()));
+ ASSERT_THAT(*mode.prog_id_prefix, ResultOf(iswdigit, Eq(0)));
+
+ // The ProgID description must not be empty.
+ ASSERT_THAT(mode.prog_id_description, StrNe(L""));
+
// UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive.
if (kUseGoogleUpdateIntegration)
ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED));
« no previous file with comments | « chrome/install_static/install_constants.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698