1 // Copyright 2017 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/active_use_util.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "build/branding_buildflags.h"
10 #include "build/build_config.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(ShouldRecordActiveUse, OrdinaryCommand) {
15 base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe")));
16 #if !defined(OS_WIN) || BUILDFLAG(GOOGLE_CHROME_BRANDING)
17 EXPECT_TRUE(ShouldRecordActiveUse(cmd_line));
19 EXPECT_FALSE(ShouldRecordActiveUse(cmd_line));
23 // --try-chrome-again by itself shouldn't do anything, just like the
24 // OrdinaryCommand case.
25 TEST(ShouldRecordActiveUse, FakeTryChromeAgainCommand) {
26 base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe")));
27 cmd_line.AppendSwitch(switches::kTryChromeAgain);
28 #if !defined(OS_WIN) || BUILDFLAG(GOOGLE_CHROME_BRANDING)
29 EXPECT_TRUE(ShouldRecordActiveUse(cmd_line));
31 EXPECT_FALSE(ShouldRecordActiveUse(cmd_line));
35 TEST(ShouldRecordActiveUse, TryChromeAgainCommand) {
36 base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe")));
37 cmd_line.AppendSwitchASCII(switches::kTryChromeAgain, "0");
39 EXPECT_FALSE(ShouldRecordActiveUse(cmd_line));