mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix device type to string.
PiperOrigin-RevId: 915051624
This commit is contained in:
committed by
Copybara-Service
parent
70e6a82927
commit
f3a18121a9
@@ -195,3 +195,16 @@ cc_test(
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "device_info_test",
|
||||
size = "small",
|
||||
timeout = "moderate",
|
||||
srcs = ["device_info_test.cc"],
|
||||
deps = [
|
||||
":types",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -31,23 +31,6 @@ class DeviceInfo {
|
||||
public:
|
||||
enum class ScreenStatus { kUndetermined = 0, kLocked, kUnlocked };
|
||||
enum class DeviceType { kUnknown = 0, kPhone, kTablet, kLaptop };
|
||||
template <typename Sink>
|
||||
void AbslStringify(Sink& sink, DeviceType device_type) {
|
||||
switch (device_type) {
|
||||
case DeviceType::kUnknown:
|
||||
sink.Append("Unknown");
|
||||
return;
|
||||
case DeviceType::kPhone:
|
||||
sink.Append("Phone");
|
||||
return;
|
||||
case DeviceType::kTablet:
|
||||
sink.Append("Tablet");
|
||||
return;
|
||||
case DeviceType::kLaptop:
|
||||
sink.Append("PC");
|
||||
return;
|
||||
}
|
||||
}
|
||||
enum class OsType {
|
||||
kUnknown = 0,
|
||||
kAndroid,
|
||||
@@ -88,6 +71,24 @@ class DeviceInfo {
|
||||
virtual bool AllowSleep() = 0;
|
||||
};
|
||||
|
||||
template <typename Sink>
|
||||
void AbslStringify(Sink& sink, DeviceInfo::DeviceType device_type) {
|
||||
switch (device_type) {
|
||||
case DeviceInfo::DeviceType::kUnknown:
|
||||
sink.Append("Unknown");
|
||||
return;
|
||||
case DeviceInfo::DeviceType::kPhone:
|
||||
sink.Append("Phone");
|
||||
return;
|
||||
case DeviceInfo::DeviceType::kTablet:
|
||||
sink.Append("Tablet");
|
||||
return;
|
||||
case DeviceInfo::DeviceType::kLaptop:
|
||||
sink.Append("PC");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
} // namespace nearby
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2026 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "internal/platform/implementation/device_info.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
|
||||
namespace nearby::api {
|
||||
namespace {
|
||||
|
||||
TEST(DeviceInfoTest, DeviceTypeToStringTest) {
|
||||
DeviceInfo::DeviceType type = DeviceInfo::DeviceType::kPhone;
|
||||
EXPECT_EQ(absl::StrCat(type), "Phone");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace nearby::api
|
||||
Reference in New Issue
Block a user