Commit f0fb5c1f authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Remove unused files from codebase.

While migrating code to new mojo type it is noticed that files
versioning_apptest.cc and versioning_test_service.cc are not used by
any platform. This CL removes unwanted code from codebase.

Bug: 955171, 978694
Change-Id: Ifcbdb7d6bb4970ff960d31129cc0bd3dc159bf00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903244Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#713498}
parent 59dfa6d9
// Copyright 2015 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.
#include <stddef.h>
#include <stdint.h>
#include "base/macros.h"
#include "mojo/public/interfaces/bindings/tests/versioning_test_client.mojom.h"
#include "services/service_manager/public/cpp/application_test_base.h"
#include "services/service_manager/public/cpp/connector.h"
namespace mojo {
namespace test {
namespace versioning {
class VersioningApplicationTest : public ApplicationTestBase {
public:
VersioningApplicationTest() : ApplicationTestBase() {}
~VersioningApplicationTest() override {}
protected:
// ApplicationTestBase overrides.
void SetUp() override {
ApplicationTestBase::SetUp();
connector()->BindInterface("versioning_test_service", &database_);
}
HumanResourceDatabasePtr database_;
private:
DISALLOW_COPY_AND_ASSIGN(VersioningApplicationTest);
};
TEST_F(VersioningApplicationTest, Struct) {
// The service side uses a newer version of Employee defintion.
// The returned struct should be truncated.
EmployeePtr employee(Employee::New());
employee->employee_id = 1;
employee->name = "Homer Simpson";
employee->department = DEPARTMENT_DEV;
database_->QueryEmployee(1, true,
[&employee](EmployeePtr returned_employee,
Array<uint8_t> returned_finger_print) {
EXPECT_TRUE(employee->Equals(*returned_employee));
EXPECT_FALSE(returned_finger_print.is_null());
});
database_.WaitForIncomingResponse();
// Passing a struct of older version to the service side works.
EmployeePtr new_employee(Employee::New());
new_employee->employee_id = 2;
new_employee->name = "Marge Simpson";
new_employee->department = DEPARTMENT_SALES;
database_->AddEmployee(new_employee.Clone(),
[](bool success) { EXPECT_TRUE(success); });
database_.WaitForIncomingResponse();
database_->QueryEmployee(
2, false, [&new_employee](EmployeePtr returned_employee,
Array<uint8_t> returned_finger_print) {
EXPECT_TRUE(new_employee->Equals(*returned_employee));
EXPECT_TRUE(returned_finger_print.is_null());
});
database_.WaitForIncomingResponse();
}
TEST_F(VersioningApplicationTest, QueryVersion) {
EXPECT_EQ(0u, database_.version());
database_.QueryVersion([](uint32_t version) { EXPECT_EQ(1u, version); });
database_.WaitForIncomingResponse();
EXPECT_EQ(1u, database_.version());
}
TEST_F(VersioningApplicationTest, RequireVersion) {
EXPECT_EQ(0u, database_.version());
database_.RequireVersion(1);
EXPECT_EQ(1u, database_.version());
database_->QueryEmployee(3, false,
[](EmployeePtr returned_employee,
Array<uint8_t> returned_finger_print) {});
database_.WaitForIncomingResponse();
EXPECT_FALSE(database_.encountered_error());
// Requiring a version higher than what the service side implements will close
// the pipe.
database_.RequireVersion(3);
EXPECT_EQ(3u, database_.version());
database_->QueryEmployee(1, false,
[](EmployeePtr returned_employee,
Array<uint8_t> returned_finger_print) {});
database_.WaitForIncomingResponse();
EXPECT_TRUE(database_.encountered_error());
}
TEST_F(VersioningApplicationTest, CallNonexistentMethod) {
EXPECT_EQ(0u, database_.version());
Array<uint8_t> new_finger_print(128);
for (size_t i = 0; i < 128; ++i)
new_finger_print[i] = i + 13;
// Although the client side doesn't know whether the service side supports
// version 1, calling a version 1 method succeeds as long as the service side
// supports version 1.
database_->AttachFingerPrint(1, new_finger_print.Clone(),
[](bool success) { EXPECT_TRUE(success); });
database_.WaitForIncomingResponse();
// Calling a version 2 method (which the service side doesn't support) closes
// the pipe.
database_->ListEmployeeIds([](Array<uint64_t> ids) { EXPECT_TRUE(false); });
database_.WaitForIncomingResponse();
EXPECT_TRUE(database_.encountered_error());
}
} // namespace versioning
} // namespace examples
} // namespace mojo
// Copyright 2015 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.
#include <stdint.h>
#include <map>
#include <utility>
#include "base/bind.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h"
#include "services/service_manager/public/c/main.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_runner.h"
namespace mojo {
namespace test {
namespace versioning {
struct EmployeeInfo {
public:
EmployeeInfo() {}
EmployeePtr employee;
Array<uint8_t> finger_print;
private:
DISALLOW_COPY_AND_ASSIGN(EmployeeInfo);
};
class HumanResourceDatabaseImpl : public HumanResourceDatabase {
public:
explicit HumanResourceDatabaseImpl(
InterfaceRequest<HumanResourceDatabase> request)
: strong_binding_(this, std::move(request)) {
// Pretend that there is already some data in the system.
EmployeeInfo* info = new EmployeeInfo();
employees_[1] = info;
info->employee = Employee::New();
info->employee->employee_id = 1;
info->employee->name = "Homer Simpson";
info->employee->department = DEPARTMENT_DEV;
info->employee->birthday = Date::New();
info->employee->birthday->year = 1955;
info->employee->birthday->month = 5;
info->employee->birthday->day = 12;
info->finger_print.resize(1024);
for (uint32_t i = 0; i < 1024; ++i)
info->finger_print[i] = i;
}
~HumanResourceDatabaseImpl() override {
for (auto iter = employees_.begin(); iter != employees_.end(); ++iter)
delete iter->second;
}
void AddEmployee(EmployeePtr employee,
const AddEmployeeCallback& callback) override {
uint64_t id = employee->employee_id;
if (employees_.find(id) == employees_.end())
employees_[id] = new EmployeeInfo();
employees_[id]->employee = std::move(employee);
callback.Run(true);
}
void QueryEmployee(uint64_t id,
bool retrieve_finger_print,
const QueryEmployeeCallback& callback) override {
if (employees_.find(id) == employees_.end()) {
callback.Run(nullptr, Array<uint8_t>());
return;
}
callback.Run(employees_[id]->employee.Clone(),
retrieve_finger_print ? employees_[id]->finger_print.Clone()
: Array<uint8_t>());
}
void AttachFingerPrint(uint64_t id,
Array<uint8_t> finger_print,
const AttachFingerPrintCallback& callback) override {
if (employees_.find(id) == employees_.end()) {
callback.Run(false);
return;
}
employees_[id]->finger_print = std::move(finger_print);
callback.Run(true);
}
private:
std::map<uint64_t, EmployeeInfo*> employees_;
StrongBinding<HumanResourceDatabase> strong_binding_;
};
class HumanResourceSystemServer : public service_manager::Service {
public:
HumanResourceSystemServer() {
registry_.AddInterface<HumanResourceDatabase>(
base::Bind(&HumanResourceSystemServer::Create, base::Unretained(this)));
}
// service_manager::Service implementation.
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override {
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void Create(HumanResourceDatabaseRequest request) {
// It will be deleted automatically when the underlying pipe encounters a
// connection error.
new HumanResourceDatabaseImpl(std::move(request));
}
private:
service_manager::BinderRegistry registry_;
};
} // namespace versioning
} // namespace test
} // namespace mojo
MojoResult ServiceMain(MojoHandle request) {
mojo::ServiceRunner runner(
new mojo::test::versioning::HumanResourceSystemServer());
return runner.Run(request);
}
......@@ -463,20 +463,6 @@ mojom("test_associated_interfaces") {
scramble_message_ids = false
}
mojom("versioning_test_service_interfaces") {
testonly = true
sources = [
"versioning_test_service.mojom",
]
}
mojom("versioning_test_client_interfaces") {
testonly = true
sources = [
"versioning_test_client.mojom",
]
}
mojom("test_wtf_types") {
testonly = true
......
// Copyright 2015 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.
module mojo.test.versioning;
// versioning_test_service.mojom and versioning_test_client.mojom contain
// different versions of Mojom definitions for a fictitious human resource
// management system. They are used to test the versioning mechanism.
enum Department {
SALES,
DEV
};
struct Employee {
uint64 employee_id;
string name;
Department department;
};
interface HumanResourceDatabase {
AddEmployee(Employee employee) => (bool success);
QueryEmployee(uint64 id, [MinVersion=1] bool retrieve_finger_print)
=> (Employee? employee, [MinVersion=1] array<uint8>? finger_print);
[MinVersion=1]
AttachFingerPrint(uint64 id, array<uint8> finger_print)
=> (bool success);
[MinVersion=2]
ListEmployeeIds() => (array<uint64>? ids);
};
// Copyright 2015 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.
module mojo.test.versioning;
// versioning_test_service.mojom and versioning_test_client.mojom contain
// different versions of Mojom definitions for a fictitious human resource
// management system. They are used to test the versioning mechanism.
enum Department {
SALES,
DEV
};
struct Date {
uint16 year;
uint8 month;
uint8 day;
};
struct Employee {
uint64 employee_id;
string name;
Department department;
[MinVersion=1] Date? birthday;
};
interface HumanResourceDatabase {
AddEmployee(Employee employee) => (bool success);
QueryEmployee(uint64 id, [MinVersion=1] bool retrieve_finger_print)
=> (Employee? employee, [MinVersion=1] array<uint8>? finger_print);
[MinVersion=1]
AttachFingerPrint(uint64 id, array<uint8> finger_print)
=> (bool success);
};
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