Commit 10fd066e authored by zengster's avatar zengster Committed by Commit bot

Added test file for SystemInfo.m, on top of the initial commit for Chrome meta installer.

Just look at BUILD.gn and SystemInfo_test.mm, everything else is consistent with CL 2094583004 (Initial commit for Chrome meta installer https://codereview.chromium.org/2094583004/)

BUG=

patch from issue 2106523002 at patchset 60001 (http://crrev.com/2106523002#ps60001)

Review-Url: https://codereview.chromium.org/2137743002
Cr-Commit-Position: refs/heads/master@{#407573}
parent 2d466aa5
......@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//testing/test.gni")
static_library("mac_installer_base") {
sources = [
"Downloader.m",
......@@ -21,9 +23,19 @@ executable("mac_installer") {
deps = [
":mac_installer_base",
]
libs = [
"AppKit.framework",
"CoreFoundation.framework",
"Foundation.framework",
libs = [ "Foundation.framework" ]
}
test("mac_installer_test") {
sources = [
"testing/OmahaXMLRequest_test.mm",
"testing/SystemInfo_test.mm",
]
deps = [
":mac_installer_base",
"//base:base",
"//base/test:run_all_unittests",
"//testing/gtest:gtest",
]
libs = [ "Foundation.framework" ]
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/installer/mac/app/OmahaXMLRequest.h"
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
TEST(OmahaXMLRequestTest, CreateReturnsValidXML) {
base::scoped_nsobject<NSXMLDocument> xml_body_(
[OmahaXMLRequest createXMLRequestBody]);
ASSERT_TRUE(xml_body_);
NSString* requestDTDLocation = [[[[NSBundle mainBundle] bundlePath]
stringByAppendingPathComponent:
@"../../chrome/installer/mac/app/testing/requestCheck.dtd"]
stringByResolvingSymlinksInPath];
NSData* requestDTDData = [NSData dataWithContentsOfFile:requestDTDLocation];
ASSERT_TRUE(requestDTDData);
NSError* error;
NSXMLDTD* requestXMLChecker =
[[NSXMLDTD alloc] initWithData:requestDTDData options:0 error:&error];
[requestXMLChecker setName:@"request"];
[xml_body_ setDTD:requestXMLChecker];
EXPECT_TRUE([xml_body_ validateAndReturnError:&error]);
}
} // namespace
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/installer/mac/app/SystemInfo.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
TEST(SystemInfoTest, GetArchReturnsExpectedString) {
NSString* arch = [SystemInfo getArch];
EXPECT_TRUE([arch isEqualToString:@"i486"] ||
[arch isEqualToString:@"x86_64h"]);
}
TEST(SystemInfoTest, GetOSVersionMatchesRegexFormat) {
NSString* os_version = [SystemInfo getOSVersion];
NSRegularExpression* regex = [NSRegularExpression
regularExpressionWithPattern:@"^10\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
options:0
error:nil];
NSUInteger matches =
[regex numberOfMatchesInString:os_version
options:0
range:NSMakeRange(0, os_version.length)];
EXPECT_EQ(1u, matches);
}
} // namespace
<!--
Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!--
Welcome to a document type declaration (DTD).
This is a document that makes sure XML files are correctly formed.
Below, |request| is implied to be the root element of the XML document, whose
children are |os| and |app|.
-->
<!ELEMENT request (os, app)>
<!--
Below, this indicates that |protocol| is a required attribute of the
|request| element; by indicating `NMTOKEN`, we indicate that this attribute
must have a value associated with it that does not contain whitespace. `CDATA`
would be the more commonly used keyword for content with whitespace.
-->
<!ATTLIST request protocol NMTOKEN #REQUIRED>
<!--
The |os| element should not have any children and cannot have any content
within the tag. (<os/> and <os></os> are allowed, but <os>stuff here!</os> is
not a valid element.)
-->
<!ELEMENT os EMPTY>
<!--
This |platform| attribute is a required attribute of |os|, and its value must
be "mac".
-->
<!ATTLIST os platform (mac) #REQUIRED>
<!--
The |version|, |arch|, and |sp| attributes are optional attributes of |os|. If
a request's XML body has the |sp|, it may not need the version or arch; if the
|sp| is not included but |version| and |arch| are specified, the XML body is
still valid. Unfortunately there is relatively less logic available for
attributes, so I currently cannot reject the XML document if there is only
either |arch| or |version|.
-->
<!ATTLIST os version NMTOKEN #IMPLIED>
<!ATTLIST os arch NMTOKEN #IMPLIED>
<!ATTLIST os sp NMTOKEN #IMPLIED>
<!--
|app| has only one child, |updatecheck|.
-->
<!ELEMENT app (updatecheck)>
<!--
The |appid| attribute of the |app| element must have "com.google.Chrome" as
its value.
-->
<!ATTLIST app appid (com.google.Chrome) #REQUIRED>
<!--
The following two attributes are required; their values must not contain
whitespace.
-->
<!ATTLIST app version NMTOKEN #REQUIRED>
<!ATTLIST app lang NMTOKEN #REQUIRED>
<!--
|updatecheck| must be an empty element.
-->
<!ELEMENT updatecheck EMPTY>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment