Greg Thompson | 85bd488c | 2017-06-08 09:18:11 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "chrome/browser/active_use_util.h" |
| 6 | |
| 7 | #include "base/command_line.h" |
| 8 | #include "base/files/file_path.h" |
| 9 | #include "build/build_config.h" |
| 10 | #include "chrome/common/chrome_switches.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | TEST(ShouldRecordActiveUse, OrdinaryCommand) { |
| 14 | base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe"))); |
| 15 | #if !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) |
| 16 | EXPECT_TRUE(ShouldRecordActiveUse(cmd_line)); |
| 17 | #else |
| 18 | EXPECT_FALSE(ShouldRecordActiveUse(cmd_line)); |
| 19 | #endif |
| 20 | } |
| 21 | |
Greg Thompson | df00c4b | 2017-11-15 19:52:34 | [diff] [blame] | 22 | // --try-chrome-again by itself shouldn't do anything, just like the |
| 23 | // OrdinaryCommand case. |
| 24 | TEST(ShouldRecordActiveUse, FakeTryChromeAgainCommand) { |
| 25 | base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe"))); |
| 26 | cmd_line.AppendSwitch(switches::kTryChromeAgain); |
| 27 | #if !defined(OS_WIN) || defined(GOOGLE_CHROME_BUILD) |
| 28 | EXPECT_TRUE(ShouldRecordActiveUse(cmd_line)); |
| 29 | #else |
| 30 | EXPECT_FALSE(ShouldRecordActiveUse(cmd_line)); |
| 31 | #endif |
| 32 | } |
| 33 | |
Greg Thompson | 85bd488c | 2017-06-08 09:18:11 | [diff] [blame] | 34 | TEST(ShouldRecordActiveUse, TryChromeAgainCommand) { |
| 35 | base::CommandLine cmd_line(base::FilePath(FILE_PATH_LITERAL("foo.exe"))); |
| 36 | cmd_line.AppendSwitchASCII(switches::kTryChromeAgain, "0"); |
| 37 | |
| 38 | EXPECT_FALSE(ShouldRecordActiveUse(cmd_line)); |
| 39 | } |