summaryrefslogtreecommitdiffstats
path: root/o3d/core/cross
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 02:47:27 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 02:47:27 +0000
commit27dd7dd56fb606b31bfd34317408a41c6eadaadc (patch)
tree04e449fde46ccae9a97528c87fe42a40c93cfa65 /o3d/core/cross
parentcf39cbb452bc000750212271cb9360052631d99c (diff)
downloadchromium_src-27dd7dd56fb606b31bfd34317408a41c6eadaadc.zip
chromium_src-27dd7dd56fb606b31bfd34317408a41c6eadaadc.tar.gz
chromium_src-27dd7dd56fb606b31bfd34317408a41c6eadaadc.tar.bz2
Small fix for IMC UPDATE_TEXTURE_2D
Review URL: http://codereview.chromium.org/173036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross')
-rw-r--r--o3d/core/cross/message_queue.cc2
-rw-r--r--o3d/core/cross/message_queue_test.cc125
2 files changed, 115 insertions, 12 deletions
diff --git a/o3d/core/cross/message_queue.cc b/o3d/core/cross/message_queue.cc
index f5828a4..eba90ae 100644
--- a/o3d/core/cross/message_queue.cc
+++ b/o3d/core/cross/message_queue.cc
@@ -606,7 +606,7 @@ bool MessageQueue::ProcessMessageUpdateTexture2D(
if (remain) {
int width = remain / image::ComputePitch(texture_object->format(), 1);
texture_object->SetRect(
- message.level, rows, 0, width, 1,
+ message.level, 0, rows, width, 1,
AddPointerOffset<void*>(target_address, rows * pitch), pitch);
}
diff --git a/o3d/core/cross/message_queue_test.cc b/o3d/core/cross/message_queue_test.cc
index e9df153..d03b3b3 100644
--- a/o3d/core/cross/message_queue_test.cc
+++ b/o3d/core/cross/message_queue_test.cc
@@ -35,6 +35,7 @@
#include "core/cross/message_queue.h"
#include "core/cross/object_manager.h"
#include "core/cross/pack.h"
+#include "core/cross/error_status.h"
#include "core/cross/service_dependency.h"
#include "core/cross/texture.h"
#include "core/cross/types.h"
@@ -574,6 +575,7 @@ class MessageQueueTest : public testing::Test {
protected:
MessageQueueTest()
: object_manager_(g_service_locator),
+ error_status_(g_service_locator),
socket_handles_(NULL),
num_socket_handles_(0) {}
@@ -588,8 +590,16 @@ class MessageQueueTest : public testing::Test {
Pack* pack() { return pack_; }
+ // Checks if an error has occured on the client then clears the error.
+ bool CheckErrorExists() {
+ bool have_error = !error_status_.GetLastError().empty();
+ error_status_.ClearLastError();
+ return have_error;
+ }
+
private:
ServiceDependency<ObjectManager> object_manager_;
+ ErrorStatus error_status_;
Pack *pack_;
nacl::Handle* socket_handles_;
int num_socket_handles_;
@@ -704,6 +714,7 @@ TEST_F(MessageQueueTest, Initialize) {
EXPECT_EQ(0U, socket_addr.find("o3d"));
delete message_queue;
+ EXPECT_FALSE(CheckErrorExists());
}
// Tests that the a client can actually establish a connection to the
@@ -733,6 +744,7 @@ TEST_F(MessageQueueTest, TestConnection) {
Provider provider;
RunTests(1, TimeDelta::FromSeconds(1), &provider);
+ EXPECT_FALSE(CheckErrorExists());
}
// Tests a request for shared memory.
@@ -783,12 +795,90 @@ TEST_F(MessageQueueTest, GetSharedMemory) {
// Tests a request to update a texture.
TEST_F(MessageQueueTest, UpdateTexture2D) {
class UpdateTexture2DTest : public PerThreadConnectedTest {
+ public:
+ UpdateTexture2DTest(int texture_id, int buffer_size)
+ : texture_id_(texture_id),
+ buffer_size_(buffer_size) {
+ }
+
+ void Run(MessageQueue* queue,
+ nacl::Handle socket_handle) {
+ String socket_addr = queue->GetSocketAddress();
+ TextureUpdateHelper helper;
+ if (!helper.ConnectToO3D(socket_addr.c_str(),
+ socket_handle)) {
+ FAIL_TEST("Failed to connect to O3D");
+ }
+
+ void *shared_mem_address = NULL;
+ int shared_mem_id = -1;
+ bool memory_ok = helper.RequestSharedMemory(65536,
+ &shared_mem_id,
+ &shared_mem_address);
+ if (shared_mem_id == -1) {
+ FAIL_TEST("Shared memory id was -1");
+ }
+
+ if (shared_mem_address == NULL) {
+ FAIL_TEST("Shared memory address was NULL");
+ }
+
+ if (!memory_ok) {
+ FAIL_TEST("Memory request failed");
+ }
+
+ if (!helper.RequestTextureUpdate(texture_id_,
+ 0,
+ shared_mem_id,
+ 0,
+ buffer_size_)) {
+ FAIL_TEST("RequestTextureUpdate failed");
+ }
+
+ Pass();
+ }
+
private:
int texture_id_;
+ int buffer_size_;
+ };
+ class Provider : public TestProvider {
public:
- explicit UpdateTexture2DTest(int texture_id) {
- texture_id_ = texture_id;
+ Provider(int texture_id, int buffer_size)
+ : texture_id_(texture_id),
+ buffer_size_(buffer_size) {
+ }
+
+ virtual PerThreadConnectedTest* CreateTest() {
+ return new UpdateTexture2DTest(texture_id_, buffer_size_);
+ }
+
+ private:
+ int texture_id_;
+ int buffer_size_;
+ };
+
+ Texture2D* texture = pack()->CreateTexture2D(128,
+ 128,
+ Texture::ARGB8,
+ 0,
+ false);
+
+ ASSERT_TRUE(texture != NULL);
+
+ Provider provider(texture->id(), 128 * 128 * 4);
+ RunTests(1, TimeDelta::FromSeconds(1), &provider);
+ EXPECT_FALSE(CheckErrorExists());
+}
+
+// Tests a request to update a partial texture.
+TEST_F(MessageQueueTest, UpdateTexture2DPartial) {
+ class UpdateTexture2DTest : public PerThreadConnectedTest {
+ public:
+ UpdateTexture2DTest(int texture_id, int buffer_size)
+ : texture_id_(texture_id),
+ buffer_size_(buffer_size) {
}
void Run(MessageQueue* queue,
@@ -817,33 +907,42 @@ TEST_F(MessageQueueTest, UpdateTexture2D) {
FAIL_TEST("Memory request failed");
}
- int texture_buffer_size = 128 * 128 * 4;
-
if (!helper.RequestTextureUpdate(texture_id_,
0,
shared_mem_id,
0,
- texture_buffer_size)) {
+ buffer_size_)) {
FAIL_TEST("RequestTextureUpdate failed");
}
Pass();
}
- };
- class Provider : public TestProvider {
private:
int texture_id_;
+ int buffer_size_;
+ };
+ class Provider : public TestProvider {
public:
- explicit Provider(int texture_id) : texture_id_(texture_id) {}
+ Provider(int texture_id, int buffer_size)
+ : texture_id_(texture_id),
+ buffer_size_(buffer_size) {
+ }
virtual PerThreadConnectedTest* CreateTest() {
- return new UpdateTexture2DTest(texture_id_);
+ return new UpdateTexture2DTest(texture_id_, buffer_size_);
}
+
+ private:
+ int texture_id_;
+ int buffer_size_;
};
- Texture2D* texture = pack()->CreateTexture2D(128,
+ // Check updating a partial texture.
+ // Because we pass in 8 * 127 * 4 + 4 that means we'll update
+ // 127 rows and 1 pixel in the last row.
+ Texture2D* texture = pack()->CreateTexture2D(8,
128,
Texture::ARGB8,
0,
@@ -851,8 +950,9 @@ TEST_F(MessageQueueTest, UpdateTexture2D) {
ASSERT_TRUE(texture != NULL);
- Provider provider(texture->id());
+ Provider provider(texture->id(), 8 * 127 * 4 + 4);
RunTests(1, TimeDelta::FromSeconds(1), &provider);
+ EXPECT_FALSE(CheckErrorExists());
}
// Tests a request to update a texture.
@@ -937,6 +1037,7 @@ TEST_F(MessageQueueTest, UpdateTexture2DRect) {
Provider provider(texture->id());
RunTests(1, TimeDelta::FromSeconds(1), &provider);
+ EXPECT_FALSE(CheckErrorExists());
}
namespace {
@@ -1004,6 +1105,7 @@ TEST_F(MessageQueueTest, RegisterAndUnregisterSharedMemory) {
Provider provider;
RunTests(1, TimeDelta::FromSeconds(1), &provider);
+ EXPECT_FALSE(CheckErrorExists());
}
// Tests that multiple concurrent clients of the MessageQueue don't
@@ -1018,6 +1120,7 @@ TEST_F(MessageQueueTest, ConcurrentSharedMemoryOperations) {
Provider provider;
RunTests(2, TimeDelta::FromSeconds(6), &provider);
+ EXPECT_FALSE(CheckErrorExists());
}
} // namespace o3d