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.
4
5#include "chrome/browser/task_manager/task_manager_util.h"
6
7#include "base/basictypes.h"
8#include "chrome/grit/generated_resources.h"
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace task_manager {
12
13namespace util {
14
15TEST(TaskManagerUtilTest, GetMessagePrefixID) {
16  struct Configuration {
17    bool is_app;
18    bool is_extension;
19    bool is_incognito;
20    bool is_prerender;
21    bool is_background;
22    int expected_result;
23  };
24  const Configuration configs[] = {
25      // Use implicit int->bool conversion to save space and keep alignment.
26      {1, 0, 0, 0, 1, IDS_TASK_MANAGER_BACKGROUND_PREFIX},
27      {1, 0, 1, 0, 0, IDS_TASK_MANAGER_APP_INCOGNITO_PREFIX},
28      {1, 0, 0, 0, 0, IDS_TASK_MANAGER_APP_PREFIX},
29      {0, 1, 1, 0, 0, IDS_TASK_MANAGER_EXTENSION_INCOGNITO_PREFIX},
30      {0, 1, 0, 0, 0, IDS_TASK_MANAGER_EXTENSION_PREFIX},
31      {0, 0, 0, 1, 0, IDS_TASK_MANAGER_PRERENDER_PREFIX},
32      {0, 0, 1, 0, 0, IDS_TASK_MANAGER_TAB_INCOGNITO_PREFIX},
33      {0, 0, 0, 0, 0, IDS_TASK_MANAGER_TAB_PREFIX}};
34  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(configs); ++i) {
35    EXPECT_EQ(configs[i].expected_result,
36              GetMessagePrefixID(configs[i].is_app,
37                                 configs[i].is_extension,
38                                 configs[i].is_incognito,
39                                 configs[i].is_prerender,
40                                 configs[i].is_background));
41  }
42}
43
44} //  namespace util
45
46} //  namespace task_manager
47